Jump to content

wheres the error?


hoponhiggo

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.