Page 1 of 1

Parse error: syntax error, unexpected ‘&’, expecting T_V

Posted: Thu Dec 24, 2009 4:17 am
by ureshpatel5
Hi,
I am running same code over my sub domain and localhost successfully .
<Sub domain link : http://estate.alakmalak.net/list.php >

And i have upload it on another server it gives me such error.

Parse error: syntax error, unexpected ‘&’, expecting T_VARIABLE or ‘$’.....

<original link : http://www.theeverafterestate.com/secure/list.php >

Can anyone help why this error occur ?

ureshpatel5@gmail.com

Re: Parse error: syntax error, unexpected ‘&’, expecting T_V

Posted: Tue Jan 19, 2010 12:19 am
by MichaelR
You have a "&" sign where it shouldn't be on whatever line the error tells you. Try posting the code here. It'll be easier for us to help you.

Re: Parse error: syntax error, unexpected ‘&’, expecting T_V

Posted: Tue Jan 19, 2010 12:27 pm
by McInfo
The most likely scenario is that PHP 5 code is being run on a PHP 4 server. In PHP 4, accessing array elements by reference in a foreach loop will trigger the error. This is a valid syntax in PHP 5.

Code: Select all

foreach ($array as &$item);
See "Example #3 Collection" on this manual page.

Another scenario that triggers this error is

Code: Select all

$a = $&b;
For this, there are two possibilities:
  • The ampersand (&) is meant to come before the dollar sign ($) so the variable $b can be accessed by reference.
  • The ampersand is a typographical error.
In this scenario, the error appears differently depending on the PHP version:
PHP 4.4.8 wrote:Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in ... on line ...
PHP 5.2.8 wrote:Parse error: parse error, expecting `T_VARIABLE' or `'$'' in ... on line ...
Edit: This post was recovered from search engine cache.