maxudaskin Posted July 23, 2007 Share Posted July 23, 2007 How would I make the following into a proper MySQL Query? mysql_query("SELECT * FROM `users` WHERE `pid`='{echo $_SESSION('username')}'"); Quote Link to comment https://forums.phpfreaks.com/topic/61401-session-in-mysql-query/ Share on other sites More sharing options...
trq Posted July 23, 2007 Share Posted July 23, 2007 mysql_query("SELECT * FROM users WHERE pid = '{$_SESSION['username']}'"); Quote Link to comment https://forums.phpfreaks.com/topic/61401-session-in-mysql-query/#findComment-305575 Share on other sites More sharing options...
cooldude832 Posted July 23, 2007 Share Posted July 23, 2007 Yes/no, but mainly NO first its best to recall the session to a variable so you don't spend your life dealing with quotes like $var = $_SESSION['var']; then you aren't echoing it but using it so you say WHERE field = '$var' NOT WHERE field = echo '$var'; echo is for creating output not for using a variables value Quote Link to comment https://forums.phpfreaks.com/topic/61401-session-in-mysql-query/#findComment-305577 Share on other sites More sharing options...
cooldude832 Posted July 23, 2007 Share Posted July 23, 2007 thrope after 2 more post go buy a lotto ticket Quote Link to comment https://forums.phpfreaks.com/topic/61401-session-in-mysql-query/#findComment-305579 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.