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')}'"); 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']}'"); 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 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 Link to comment https://forums.phpfreaks.com/topic/61401-session-in-mysql-query/#findComment-305579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.