Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.