yogibear Posted August 13, 2008 Share Posted August 13, 2008 Hi I have a mysql query and I want to use a session to select from the database WHERE username equals the contents of the session. Sorry if I have not been clear, I am finding it difficult to explain. My attempt at the code may make it easier to understand what I am trying to do. $result = mysql_query("SELECT * FROM User WHERE Username='$_SESSION["username"]'"); I have tried this code but I get an error. Best wishes yogi Quote Link to comment https://forums.phpfreaks.com/topic/119470-solved-mysql-session/ Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 id would help to see the error and the whole code. first off, can you echo $_session['username']; ? Quote Link to comment https://forums.phpfreaks.com/topic/119470-solved-mysql-session/#findComment-615425 Share on other sites More sharing options...
sasa Posted August 13, 2008 Share Posted August 13, 2008 try $result = mysql_query("SELECT * FROM User WHERE Username='$_SESSION[username]'"); Quote Link to comment https://forums.phpfreaks.com/topic/119470-solved-mysql-session/#findComment-615431 Share on other sites More sharing options...
discomatt Posted August 13, 2008 Share Posted August 13, 2008 try $result = mysql_query("SELECT * FROM User WHERE Username='$_SESSION[username]'"); More syntactically correct, but technically there's nothing wrong with your code $result = mysql_query("SELECT * FROM User WHERE Username='{$_SESSION['username']}'"); Quote Link to comment https://forums.phpfreaks.com/topic/119470-solved-mysql-session/#findComment-615432 Share on other sites More sharing options...
yogibear Posted August 13, 2008 Author Share Posted August 13, 2008 Hi Thanks for your help, it works perfectly now. Can I say that is some seriously fast response times, very impressive. Best wishes Yogi Quote Link to comment https://forums.phpfreaks.com/topic/119470-solved-mysql-session/#findComment-615438 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.