supermerc Posted May 20, 2007 Share Posted May 20, 2007 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()); Quote Link to comment https://forums.phpfreaks.com/topic/52275-parse-error/ Share on other sites More sharing options...
radar Posted May 20, 2007 Share Posted May 20, 2007 change that line to this.. $all_requests = mysql_query("SELECT * FROM friends WHERE userid='$profile_info[id]' AND state=1 ORDER BY RAND() LIMIT 5") or die(mysql_error()); and it should work... Quote Link to comment https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257918 Share on other sites More sharing options...
akitchin Posted May 21, 2007 Share Posted May 21, 2007 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]. Quote Link to comment https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257934 Share on other sites More sharing options...
btherl Posted May 21, 2007 Share Posted May 21, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257973 Share on other sites More sharing options...
akitchin Posted May 21, 2007 Share Posted May 21, 2007 i suppose when using double quotes, interpolation becomes the rate-limiting process. my source on the claim is: http://www.moskalyuk.com/blog/php-optimization-tips/1272 just read it the other day. has some interesting notes. Quote Link to comment https://forums.phpfreaks.com/topic/52275-parse-error/#findComment-257997 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.