hoponhiggo Posted June 14, 2011 Share Posted June 14, 2011 Hi Guys Can anybody tell me where the "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in " is in this peice of code $get = mysql_query( "SELECT * FROM `friend_requests` WHERE 'username' = `$_SESSION['MM_Username']`"); if i shorten this to $get = mysql_query( "SELECT * FROM `friend_requests`"); It works fine, so im guesing the error is somewhere in WHERE 'username' = `$_SESSION['MM_Username']`"); Thanks Link to comment https://forums.phpfreaks.com/topic/239323-wheres-the-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 14, 2011 Share Posted June 14, 2011 Php array variables inside of a double-quoted string need to be enclosed by {}, i.e. {$_SESSION['MM_Username']} Your query also has two sql syntax problems. Your username column is enclosed by single-quotes, making it a string instead of a column identifier and your $_SESSION['MM_Username'] value is enclosed by back-ticks ``, causing it to be treated as a column identifier. The $_SESSION['MM_Username'] value, which is a string data value, should be enclosed by single-quotes. Back-ticks are mysql specific and should be avoided whenever possible (you only need them when a database, table, or column name contains special characters or is a reserved mysql keyword.) With all the changes - $get = mysql_query( "SELECT * FROM friend_requests WHERE username = '{$_SESSION['MM_Username']}'"); Link to comment https://forums.phpfreaks.com/topic/239323-wheres-the-error/#findComment-1229466 Share on other sites More sharing options...
hoponhiggo Posted June 14, 2011 Author Share Posted June 14, 2011 aah...I see. Thank you very much Link to comment https://forums.phpfreaks.com/topic/239323-wheres-the-error/#findComment-1229467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.