Jump to content

parse error


supermerc

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

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.