Hello community,
I have trouble to read my database and tried a lot of things the last hours.
When I use the following GET-Message in my browsers address bar:
http://127.0.0.1/SelectUserDetailsFacebookUser.php?UserID=8368845343374843
I get the following result:
83688453433748430 results
I don’t understand why it returns 0 results all the time.
Instead of
bind_param(‘s’, $userID);
I also tried
bind_param(“s”, $userID);
I also checked the database entry and tried to use the TRIM Function in the case there is a blank space in the user_id. Unfortunately, with no success.
Have you any ideas?
Thank you so much in advance!
Greetings, Christopher.
Here is my code:
<?php $mysqli = new mysqli("127.0.0.1", "root", "", "digitalcoursedb"); if (mysqli_connect_error()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } else { if (isset($_GET['UserID'])) { $userID = (string) $_GET['UserID']; echo $userID; $stmt = $mysqli->prepare("SELECT * FROM users WHERE user_id = ?"); $stmt->bind_param('s', $userID); $stmt->execute(); if ($stmt->num_rows > 0) { echo json_encode($results); while ($row = $stmt->fetch()) { print_r($row); } echo json_encode($userDetails); } else { echo "0 results"; } } } $mysqli->close(); ?>