fork download
  1.  
  2. <?php
  3. class database
  4. {
  5. public $host = "localhost";
  6. public $user = "root";
  7. public $pass = "";
  8. public $db = "db";
  9. public $link;
  10.  
  11.  
  12. public function __construct()
  13. {
  14. $this->connect();
  15. }
  16.  
  17.  
  18. private function connect()
  19. {
  20. $this->link = new mysqli($this->host, $this->user, $this->pass, $this->db);
  21. return $this->link;
  22. }
  23.  
  24. public function select($query)
  25. {
  26. $result = $this->link->query($query) or die($this->link->error.__LINE__);
  27. if($result->num_rows > 0)
  28. {
  29. return $result;
  30. }
  31. else
  32. {
  33. return false;
  34. }
  35. }
  36.  
  37.  
  38. public function insert($query)
  39. {
  40. $insert_row = $this->link->query($query) or die($this->link->error.__LINE__);
  41.  
  42. if($insert_row)
  43. {
  44. = echo "Insert Successfully ";
  45. }
  46. else
  47. {
  48. die('Error : ('. $this->link->errno .') '. $this->link->error);
  49. }
  50. }
  51.  
  52. public function update($query)
  53. {
  54. $update_row = $this->link->query($query) or die($this->link->error.__LINE__);
  55.  
  56. //Validate Insert
  57. if($update_row)
  58. {
  59. echo "Update Successfully";
  60. exit();
  61. }
  62. else
  63. {
  64. die('Error : ('. $this->link->errno .') '. $this->link->error);
  65. }
  66. }
  67.  
  68.  
  69. public function delete($query)
  70. {
  71. $delete_row = $this->link->query($query) or die($this->link->error.__LINE__);
  72.  
  73. if($delete_row)
  74. {
  75. echo "Delete Successfully";
  76. }
  77. else
  78. {
  79. die('Error : ('. $this->link->errno .') '. $this->link->error);
  80. }
  81. }
  82. }
  83. ?>
Runtime error #stdin #stdout #stderr 0.01s 82880KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected '=' in /home/caTqNo/prog.php on line 44