herghost Posted September 26, 2009 Share Posted September 26, 2009 Hi All, Should be a simple one I hope, think I am just missing some logic somewhere. I have this: $query="SELECT user_id FROM forum_question WHERE username =" . $_SESSION['username'] .""; $result=mysql_query($query) or die ("oh dear " .mysql_error()) ; while($rows=mysql_fetch_array($result)) { $_SESSION['user_id'] = $rows['user_id']; } Which is just meant to set the session from a the users id in the database. Now I am logged in as user 'admin', However I am getting the error 'oh dear Unknown column 'admin' in 'where clause' However when I double checked my database, admin is definitly listed on a row and has posted a question. What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/175586-solved-database-query-help/ Share on other sites More sharing options...
Philip Posted September 26, 2009 Share Posted September 26, 2009 $query="SELECT user_id FROM forum_question WHERE username =" . $_SESSION['username'] .""; should be $query="SELECT user_id FROM forum_question WHERE username = '" . $_SESSION['username'] ."'"; Notice the single quotes. Quote Link to comment https://forums.phpfreaks.com/topic/175586-solved-database-query-help/#findComment-925259 Share on other sites More sharing options...
herghost Posted September 26, 2009 Author Share Posted September 26, 2009 lovely, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/175586-solved-database-query-help/#findComment-925264 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.