Jump to content

Recommended Posts

This is the error:

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/randomy/public_html/profile.php on line 103

 

This is line 103:

 

$all_requests = mysql_query("SELECT * FROM friends WHERE userid='$profile_info['id']' AND state=1 ORDER BY RAND() LIMIT 5") or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/52275-parse-error/
Share on other sites

i would suggest retaining your array index delimiters and instead adding braces:

 

$all_requests = mysql_query("SELECT * FROM friends WHERE userid='{$profile_info['id']}' AND state=1 ORDER BY RAND() LIMIT 5") or die(mysql_error());

 

either solution will work, although $array['id'] is several times faster than $array[id].

Link to comment
https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257934
Share on other sites

I tested your claim, akitchin..

 

$a = "$arr[id]";

 

is much the same speed as

 

$a = "{$arr['id']";

 

But,

 

$a = $arr[id];

 

is three times slower than

 

$a = $arr['id'];

 

Very interesting results there.. it seems that the presence of double quotes changes things greatly.

 

Results for 5 million runs of each statements were:

 

$a = $arr[id]; # 15 seconds

$a = $arr['id']; # 5 seconds

$a = "$arr[id]"; # 9.5 seconds

$a = "{$arr['id']}"; # 9.5 seconds

Link to comment
https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257973
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.