Parse error: parse error, unexpected '&', expecting ','

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Neobis
New php-forum User
New php-forum User
Posts: 5
Joined: Sat Jul 20, 2002 3:42 am

Parse error: parse error, unexpected '&', expecting ','

Postby Neobis » Sat Jul 20, 2002 3:50 am

Hi can somebody help, I am new to PHP and I am getting this error message:

Parse error: parse error, unexpected '&', expecting ',' or ';' in ..... on line 28

Any help would be greatly appreciated.

Thank in advance.

N.

Code Below
===========
<TABLE width="100%" border="0" cellpadding="10" cellspacing="0">
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Pos</td>
<td class="EventTitle" valign="top" align="left" bgcolor="#D0F0D0">Team Name</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Played</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Won</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Drawn</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Lost</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">+ / -</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D1D1E9">Points</td>
<td class="EventTitle" valign="top" align="right" bgcolor="white">Last 6</td>
</tr>
<?
$db_handle = mysql_connect("default","root","");
msql_select_db("fixtures",$db_handle);
$myquery = msql_query("SELECT TableDate, Position, TeamID, TeamName, Played, Won, Drawn, Lost, GoalDifference, Points, TeamForm FROM LeagueTable",$db_handle);

while($rs = msql_fetch_array($myquery)){
if($BGColor == "#F7F7E7"){
$BGColor="#E7E7D6" ;
} else {
$BGColor="#F7F7E7";
}
?>
<div ALIGN="center">
<tr BGCOLOR="<?$BGColor?>">
<td class="description" valign="top" align="center"><?=&rs["Position"]?></td>
<td class="description" valign="top" align="left"><?=$rs["TeamName"]?></td>
<!--td class="description" valign="top" align="left"><a href="advanced_results.asp?TypeSearch=Team+Name&advquery=<?=rs["TeamName"]?>&B1=Search" onFocus="if(this.blur)this.blur()"><?=rs["TeamName"]?></a></td-->
<td class="description" valign="top" align="center"><?=&rs["Played"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Won"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Drawn"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Lost"]?></td>
<td class="description" valign="top" align="center"><?=&rs["GoalDifference"]?></td>
<td class="description" valign="top" align="center" bgcolor="#D1D1E9"><?=&rs("Points")?></td>
<td class="description1" valign="top" bgcolor="white" align="right"><?=&rs["TeamForm"]?></td>
</tr>
<? } ?>
</table>
</div>

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: Parse error: parse error, unexpected '&', expecting

Postby WiZARD » Sat Jul 20, 2002 6:06 am

Neobis wrote:Hi can somebody help, I am new to PHP and I am getting this error message:

Parse error: parse error, unexpected '&', expecting ',' or ';' in ..... on line 28

Any help would be greatly appreciated.

Thank in advance.

N.

Code Below
===========
<TABLE width="100%" border="0" cellpadding="10" cellspacing="0">
<table border="0" cellpadding="1" cellspacing="1" width="100%">
<tr>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Pos</td>
<td class="EventTitle" valign="top" align="left" bgcolor="#D0F0D0">Team Name</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Played</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Won</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Drawn</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">Lost</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D0F0D0">+ / -</td>
<td class="EventTitle" valign="top" align="center" bgcolor="#D1D1E9">Points</td>
<td class="EventTitle" valign="top" align="right" bgcolor="white">Last 6</td>
</tr>
<?
$db_handle = mysql_connect("default","root","");
msql_select_db("fixtures",$db_handle);
$myquery = msql_query("SELECT TableDate, Position, TeamID, TeamName, Played, Won, Drawn, Lost, GoalDifference, Points, TeamForm FROM LeagueTable",$db_handle);

while($rs = msql_fetch_array($myquery)){
if($BGColor == "#F7F7E7"){
$BGColor="#E7E7D6" ;
} else {
$BGColor="#F7F7E7";
}
?>
<div ALIGN="center">
<tr BGCOLOR="<?$BGColor?>">
<td class="description" valign="top" align="center"><?=&rs["Position"]?></td>
<td class="description" valign="top" align="left"><?=$rs["TeamName"]?></td>
<!--td class="description" valign="top" align="left"><a href="advanced_results.asp?TypeSearch=Team+Name&advquery=<?=rs["TeamName"]?>&B1=Search" onFocus="if(this.blur)this.blur()"><?=rs["TeamName"]?></a></td-->
<td class="description" valign="top" align="center"><?=&rs["Played"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Won"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Drawn"]?></td>
<td class="description" valign="top" align="center"><?=&rs["Lost"]?></td>
<td class="description" valign="top" align="center"><?=&rs["GoalDifference"]?></td>
<td class="description" valign="top" align="center" bgcolor="#D1D1E9"><?=&rs("Points")?></td>
<td class="description1" valign="top" bgcolor="white" align="right"><?=&rs["TeamForm"]?></td>
</tr>
<? } ?>
</table>
</div>


Hi!
You have a wrong code in your script you wrote:

Code: Select all

<tr BGCOLOR="<?$BGColor?>">
:?:
need write

Code: Select all

<tr BGCOLOR="<?echo ($BGColor)?>">
:!:

and next code you need change too.

Neobis
New php-forum User
New php-forum User
Posts: 5
Joined: Sat Jul 20, 2002 3:42 am

Postby Neobis » Sat Jul 20, 2002 6:42 am

Thanks wizard.

I am still getting the error :

Parse error: parse error, unexpected '&', expecting ',' or ';' in ..... on line 29

Line 29 is :

<td class="description" valign="top" align="center"><?=&rs["Position"]?></td>

Can you assist again?

Thanks.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sat Jul 20, 2002 7:26 am

Neobis wrote:Thanks wizard.

I am still getting the error :

Parse error: parse error, unexpected '&', expecting ',' or ';' in ..... on line 29

Line 29 is :

<td class="description" valign="top" align="center"><?=&rs["Position"]?></td>

an you assist again?

Thanks.


I can help you.

Code: Select all

<td class="description" valign="top" align="center"><?=$rs["Position"]; ?></td>


you forget to write ; after array element...

Jay

Postby Jay » Thu Aug 01, 2002 2:18 pm

Your loop generating the table rows is full of errors. I've highlighted them in bold for you.

The first line should be:
<tr BGCOLOR="<?=$BGColor?>"> You left out the '=' sign.

All the table cell values should be in the format:
<?=$rs["keyName"]?>
You have used the '&' sign in several instances, and sometimes nothing at all. Also, for the 'Points' value, you have used curly brackets () instead of square brackets []


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron