PHP Parse error: syntax error, unexpected '='

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mexaros
Forum Newbie
Posts: 1
Joined: Thu Mar 06, 2008 4:43 pm

PHP Parse error: syntax error, unexpected '='

Post by mexaros »

I am relatively new to php and am updating a site for a company. However whenever i try to load the site i recieve this error:
PHP Parse error: syntax error, unexpected '=' in C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs\\neighbours\\include\\left.php on line 67

Here is the code(line 67 highlighted in red):
while($row=$db->fetchArray($rec1))
{
//echo $row['product_name'];
?>
<tr>
<td align="left" class="text-9">
<a href="showoption.php?itid=<?php =$row['prod_id']?>&cat=<?php =$row['cat_id']?>">

<!-- <a href="products.php?mode=prod&prodid=&cat=<?php =$row['prod_id']?>"> --><?php echo $row['product_name'];?></a></td>
<td width="16%" align="center" class="text-9"><img src="images/arrow.jpg" width="7" height="6" /></td>
</tr>
<?php
}
$sql="select * from tbl_product";
$rec1=$db->query($sql);
$total_records=$db->numRows();
if($total_records>=20)
{
?>


could someone tell me why this is?
User avatar
HCBen
Forum Commoner
Posts: 33
Joined: Thu Jun 22, 2006 3:15 pm
Location: Indiana

Re: PHP Parse error: syntax error, unexpected '='

Post by HCBen »

I believe the space before the equal sign is the problem. Remove the space between <?php and =

-Ben
User avatar
hawkenterprises
Forum Commoner
Posts: 54
Joined: Thu Feb 28, 2008 9:56 pm
Location: gresham,oregon
Contact:

Re: PHP Parse error: syntax error, unexpected '='

Post by hawkenterprises »

does <?php= work I thought only <?= works and that's only if you have short tags enabled.
User avatar
HCBen
Forum Commoner
Posts: 33
Joined: Thu Jun 22, 2006 3:15 pm
Location: Indiana

Re: PHP Parse error: syntax error, unexpected '='

Post by HCBen »

Not sure if it works with short-tags disabled, I can't imagine why it wouldn't, but I know <?php= works with short-tags enabled. At least with PHP5+.
I'm not running a site with short-tags disabled or with PHP4, so I'm unable to verify this.

I like me some short tags though...

Ben
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: PHP Parse error: syntax error, unexpected '='

Post by Chris Corbyn »

<?= is a short tag. "<?php echo" is the proper version ;)
Post Reply