I am trying to learn PHP5 and am having a couple of problems with it. I am working with prepared statements and am trying to run the following code:
<?php require_once 'includes/config.php'; $conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); $query = 'SELECT * FROM user_table'; if($stmt = $conn->prepare($query)) { $stmt->execute(); while ($row = $stmt->fetch()) { print_r ($row); } } ?>
I have 2 rows it should return each containing an id, login_name, login_password and a login_level.
When the statement runs it only prints the following:
11
Any help would be greatly appreciated.
The fetch() method returns
TRUE,FALSE, orNULLdepending on whether it succeeded in fetching the data. It doesn’t return the data in an array. Instead it places the results in variables bound by the bind_result() method.