Guest User

Untitled

a guest
Oct 22nd, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Notice: Undefined variable: results in C:xampphtdocsTest WebsiteIncludesdatabaseconnect.php on line 25
  2.  
  3. $dbServername = "localhost";
  4. $dbUsername = "root";
  5. $dbPassword = "";
  6. $dbName = "phplessons";
  7.  
  8. $conn = new mysqli($dbServername, $dbUsername, $dbPassword, $dbName);
  9.  
  10. if ($conn->connect_errno) {
  11. printf("Connection failed %sn", $conn->connect_error);
  12. exit();
  13. }
  14.  
  15. $id = 8;
  16. $stmt = $conn->prepare("Select * FROM posts WHERE ID=?");
  17. $stmt->bind_param("d", $id);
  18. $stmt->execute();
  19. $result = $stmt->get_result();
  20.  
  21. while ($row = $result->fetch_object()) {
  22. $results[] = $row;
  23. }
  24.  
  25. print_r($results);
  26.  
  27. ?>
Add Comment
Please, Sign In to add comment