Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php
  2.  
  3. // Turn off error reporting
  4. error_reporting(0);
  5.  
  6. $host = "127.0.0.1";
  7. $dbuser = "root";
  8. $dbpass = "ascent";
  9. $dbname = "auth";
  10. $conn = mysqli_connect($host, $dbuser, $dbpass, $dbname);
  11.  
  12. if (!conn){ // stop loading anything if there's no DB connection
  13.     print("No database connection");
  14.     exit(); // replace with a return if you want to send a message or something
  15.     }
  16.    
  17. if ($stmt = $conn->prepare("SELECT * FROM account")){ // check if we have a statement then continue
  18.     //$stmt->bind_param("i", $status); - you don't need this line because you are not passing a variable and your function will crash
  19.     $stmt->execute();
  20.     //$stmt->bind_result($charname); you don't need this either cause you are not going to use this variable
  21.     $stmt->store_result();
  22.     if($stmt->num_rows > 0)
  23.         echo $stmt->num_rows;
  24.     $stmt->close(); //make sure you always close the statement after you are done
  25. }
  26.  
  27. $conn->close(); //also you need to close the connection too
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement