Guest User

Untitled

a guest
Apr 26th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. Fatal error: Uncaught Error: Call to undefined function ClassesConnectionmysqli_connect() in C:Apache24htdocsControlePMClassesConnectionDBConnect.php:21 Stack trace: #0 C:Apache24htdocsControlePMindex.php(22): ClassesConnectionDBConnect->connect() #1 {main} thrown in C:Apache24htdocsControlePMClassesConnectionDBConnect.php on line 21
  2.  
  3. <?php
  4. namespace ClassesConnection;
  5. class DBConnect
  6. {
  7. var $host;
  8. var $username;
  9. var $password;
  10. var $database;
  11. public $dbc;
  12. public $connInfo=FALSE;
  13.  
  14. public function __construct(){
  15. $this->host = 'localhost:3306';
  16. $this->username = 'root';
  17. $this->password = 'MyPassWord';
  18. $this->database = 'MyDB';
  19. }
  20. public function connect()
  21. {
  22. $conn = mysqli_connect($this->host,$this->username,$this->password,$this->database);
  23.  
  24. if (! $conn) {
  25. echo "Error: Unable to connect to MySQL." . PHP_EOL;
  26. echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
  27. echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
  28. exit;
  29. }
  30. echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
  31. echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
  32. mysqli_close($conn);
  33. }
  34. ?>
  35.  
  36. <?php
  37. require_once ('Classes/Connection/DBConnect.php');
  38. $conn = new DBConnect();
  39. $conn->connect();
  40.  
  41. if (! $conn->connInfo){
  42. $result = "Connection failed";
  43. }
  44. else $result = "Connection Succes";
  45. ?>
Add Comment
Please, Sign In to add comment