mikeshallot

Show rows

Feb 21st, 2022
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. session_name("HELLO_SESSION");
  4. session_start();
  5.  
  6. echo("Authenticating to the database...\n");
  7.  
  8. $mysqli = new mysqli("host-mysql-db", "luckybyte", "Hjbbj86cX6Nw4QK3QQNnVPFpZrZh3kXm", "luckybyte");
  9.  
  10.  
  11. if ($mysqli->connect_error){
  12.     die("Failed to authenticate to the database :( \n");
  13. }
  14.  
  15. echo("Successfully authenticated! :) \n");
  16.  
  17. $stmt = $mysqli->prepare("SELECT * FROM users;");
  18. $result = $stmt->execute();
  19.  
  20. echo("Running SQL query SELECT * FROM users;\n");
  21. echo("\n");
  22.  
  23.  
  24. ///////////////////////////////////////////////////// NEW
  25. while ( $rows = $result->fetch_assoc() ) {
  26.     print_r($rows);
  27. }
  28. ///////////////////////////////////////////////////// NEW
  29.  
  30. echo("\n");
  31. echo("Trying to bind to variable (unsure if that is what works for MySQLi)\n");
  32.  
  33. $stmt->bind_result($output);
  34. $stmt->fetch();
  35.  
  36. print_r($output);
  37.  
  38. $stmt->close();
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment