Sample Header Ad - 728x90

SELLECT * FROM Table WHERE name=$variable not working

0 votes
1 answer
50 views
I'm trying to set up a simple SQL Code to collect a users details when they log in to a new site I'm writing, but it throws an error every time. Any Ideas what. I'm doing wrong?
$sql = "SELECT * FROM Users WHERE uname = '".$uname."'";

if ($conn->query($sql) === TRUE) {
  echo "Returned rows are: " . $result -> num_rows;
  // Free result set
  $result -> free_result();
} else {
  echo "Error: " . $sql . "
" . $conn->error; }
Thee response I receive from the server is:
Error: SELECT * FROM Users WHERE uname = 'XYZ'
Asked by Simon (103 rep)
Jan 24, 2024, 11:24 AM
Last activity: Jan 24, 2024, 11:45 AM