ACBMSE Posted September 18, 2019 Share Posted September 18, 2019 (edited) I'm a newbie, can you please help? I'm getting a mysql error "Unknown column 'E0000001' in 'where clause'" The id is in the URL: ...user-profile.php?id=E0000001 My Query $query = mysqli_query($con, "SELECT * FROM UserList WHERE UserID=".$id) or die (mysqli_error($con)); Thank you Edited September 18, 2019 by ACBMSE Quote Link to comment Share on other sites More sharing options...
gw1500se Posted September 18, 2019 Share Posted September 18, 2019 There is no column named "UserID" in the table named "UserLIst". Quote Link to comment Share on other sites More sharing options...
ACBMSE Posted September 18, 2019 Author Share Posted September 18, 2019 Here is an image of the table. UserID is a column. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 18, 2019 Share Posted September 18, 2019 16 minutes ago, ACBMSE said: SELECT * FROM UserList WHERE UserID=".$id) .. therefore the query being executed is SELECT * FROM UserList WHERE UserID=E0000001 1 ) String variables in a SQL statement need to be in single quotes otherwise they are thought to be a column name. 2 ) The variable shouldn't be there at all - you should be using a prepared statement and passing the id as a parameter $query = mysqli_prepare($con, "SELECT * FROM UserList WHERE UserID = ? "); $query->bind_param('s', $id); $query->execute(); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.