Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error: expecting T_VARIABLE or '$'???? 1

Status
Not open for further replies.

pdotd

Programmer
Jun 15, 2004
29
CA
hey, i was wondering if someone could tell me what is wrong with my script, its a simple script and i think it looks fine, but whenever i run it ket this errors msg saying:

Parse error: parse error, unexpected ';', expecting T_VARIABLE or '$' in F:\Websites\mrsbsgifthouse\cart\cart.cat.productstest.php on line 28

here is my script:

<html>
<head>
<title> Product List </title>
</head>
<body bgcolor="#ffffff">
<h1>Products</h1>
<table>
<tr>
<?

$y = 7;
$count =0;

for ($x=0; $x <=$y; $x++)
{

?>


<td>
<div align="center">
<a href="localhost">OUR PRICE $18.00</a><br /></a>
</div>
</td>
<?
$count = ++;
echo $count;
if ($y = 3)
{
?>
</tr>
<tr>
<?
$count =0;
}
}
?>
</tr>
</table>
</body>
</html>
 
Help us help you. When you are relaying a PHP error report, indicate where in your code the error occurs. I think it was this line:

$count = ++;

which should read:

$count++;


but I'm not sure.

Also, switching back and forth between PHP-interpreted mode (everyting between "<?php" and "?>") and HTML-througput mode (everything else) gives PHP a performance hit. You can use multiline print statements for better performance:

Code:
<?php
print '<html>
<head>
<title> Product List </title>
</head>
<body bgcolor="#ffffff">
<h1>Products</h1>
<table>
	<tr>';
        
        $y = 7;
        $count =0;

for ($x=0; $x <=$y; $x++)
{
	print '
		<td>
                <div align="center">
                <a href="localhost">OUR PRICE $18.00</a><br /></a>
                </div>
            </td>';

	$count++;
	echo $count;
	if ($y = 3) 
	{
		print '
                </tr>
                <tr>';
                $count =0;
	}
}

print '
    </tr>
</table>
</body>
</html>';
?>


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
thanks sleipnir214,

the code now works

i will remember next time to post the line error to better help you answer my questions

pdotd
 
You also probably want
Code:
            if ($y == 3) 
            {
                ?>
                </tr>
                <tr>
                <?
                $count =0;
            }
instead of
Code:
            if ($y = 3) 
            {
                ?>
                </tr>
                <tr>
                <?
                $count =0;
            }
Notice '==' instead of '=' in your "if" statement. The way you have it now will always be true and will assign '3' to '$y'.

Ken
 
when i change my code to
if ($y == 3)
{
?>
</tr>
<tr>
<?
$count =0;
}
with my for loop = 3 it does not create a new row? it just skips the if statement

pdotd
 
pdotd:
Keep one thing in mind: of everyone in this discussion, you are the only one who understands what this code should do.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Looking at your code again... $y will never equal 3. You set it to 7 before your loop. Maybe you want to test the value of $count in your if statement.

Ken
 
you're right....sorry, that was my silly mistake for not seeing that. (i've been looking at code for too long)


thanks again

pdotd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top