Guest User

Untitled

a guest
Sep 2nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. Fatal error: Uncaught Error: Call to a member function query() on null in C:xampphtdocsa.commodulesmysql_PDO.php:44 Stack trace: #0 C:xampphtdocsa.comcontrolslist.php(20): mysql_PDO->query('SELECT * FROM s...', false) #1 C:xampphtdocsa.comindex.php(140): list_control->start() #2 {main} thrown in C:xampphtdocsa.commodulesmysql_PDO.php on line 44
  2.  
  3. class list_control
  4. {
  5.  
  6. private $lang;
  7.  
  8. function __construct($lang)
  9. {
  10. $this->lang = $lang;
  11. loadModule('mysql_PDO');
  12. }
  13.  
  14. public function start() {
  15.  
  16. global $dbc;
  17.  
  18. $db = new mysql_PDO($dbc['host'], $dbc['user'], $dbc['password'], $dbc['dbase']);
  19. $db->connect();
  20. $db->query('SELECT * FROM slug', false);
  21.  
  22. load('list', $this->lang);
  23.  
  24. $db = null;
  25.  
  26. }
  27.  
  28. }
  29.  
  30. class mysql_PDO
  31. {
  32.  
  33.  
  34. private $host;
  35. private $user;
  36. private $password;
  37. private $dbase;
  38. private $char;
  39. public $db;
  40.  
  41.  
  42. function __construct($host, $user, $password, $dbase, $char = 'UTF8mb4')
  43. {
  44. $this->host = $host;
  45. $this->user = $user;
  46. $this->password = $password;
  47. $this->dbase = $dbase;
  48. $this->char = $char;
  49.  
  50. function clearStr($str) {
  51.  
  52. $str = htmlspecialchars(trim(mysqli_real_escape_string($str)));
  53. return $str;
  54.  
  55. }
  56.  
  57.  
  58. }
  59.  
  60. public function connect() {
  61.  
  62. $db = new PDO('mysql:host='.$this->host.';dbname='.$this->dbase.'', $this->user, $this->password) or die();
  63. $db->exec('SET NAMES '.$this->char.'');
  64.  
  65. }
  66.  
  67. public function query($query, $bool = false) {
  68.  
  69. $result = $this->db->query($query); //ВОТ 44 СТРОКА
  70. $result->execute();
  71.  
  72. if ($bool == false) {
  73. $return = $result->fetchAll();
  74. return $return;
  75. } else {
  76. return $result;
  77. }
  78.  
  79. }
  80.  
  81. public function close() {
  82.  
  83. $this->db = null;
  84.  
  85. }
  86.  
  87. }
Add Comment
Please, Sign In to add comment