Advertisement
Guest User

Untitled

a guest
Feb 10th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1.  
  2.  
  3. $db = 'mysql:dbname=new_site_eaginfo; host=localhost; charset=utf8;';
  4. $user = 'root';
  5. $password = '';
  6.  
  7. try {
  8. $PDO = new PDO($db, $user, $password);
  9. $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  10.  
  11.  
  12. } catch (PDOException $e) {
  13. echo 'Connection failed: ' . $e->getMessage();
  14. }
  15.  
  16. function Error_Handling() {
  17.  
  18. global $news_name, $news_short_desc, $news_full_desc, $news_category, $news_author ;
  19.  
  20. $news_name = $_POST['news_name'];
  21. $news_short_desc = $_POST['news_short_desc'];
  22. $news_full_desc = $_POST['news_full_desc'];
  23. $news_category = $_POST['news_category'];
  24. $news_author = $_POST['news_author'];
  25.  
  26.  
  27.  
  28. } //Error_Handling()
  29. Error_Handling();
  30.  
  31.  
  32.  
  33.  
  34. class User
  35. {
  36. public $news_name;
  37. function __construct($news_name)
  38. {
  39. $this->SmallText = $news_name;
  40.  
  41. if(mb_strlen($news_name) !=0) {
  42. $query = "INSERT INTO table_news_section (news_name) VALUES (:fnews_name) ";
  43. $addData = $PDO->prepare($query);
  44. $addData -> bindParam('fnews_name', $this->SmallText = $news_name);
  45. if($addData -> execute()) {
  46. echo 'Upload Done !';
  47. }
  48. }
  49.  
  50. }
  51.  
  52. function getInfo()
  53. {
  54. echo "სახელი: $this->SmallText <br>";
  55. }
  56. }
  57.  
  58. $user2 = new User($news_name);
  59. $user2->getInfo();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement