Page 1 of 1

T_ENCAPSED_AND_WHITESPACE error?

Posted: Thu Nov 30, 2006 9:38 pm
by dbdvd7
Im trying to output a value to another page but I get this error when I try and run the below script. When I take the $ros off the page will run but won't carry over variables to the next page. Any suggestions?

error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/penguinp/public_html/extramediumapparel/membermu/viewcart.php on line 28


Code: Select all

<?

require("popupheader.inc");


$dbh=mysql_connect ("localhost", "penguinp_member", "guess");
mysql_select_db ("penguinp_XMmembers");

$result= mysql_query("SELECT * FROM CartItems")
or die(mysql_error());


echo"<table border='0' cellspacing='10' cellpadding='10'>";
echo"<tr><th>Product Name</th><th>Small</th><th>Medium</th><th>Large</th><th>XLarge</th>";

while($row = mysql_fetch_array($result)) {
	echo "<tr><td><div align='center'>";
	echo $row['product_name'];
	echo "</div></td><td><div align='center'>";
	echo $row['Small'];
	echo "</div></td><td><div align='center'>";
	echo $row['Medium'];
	echo "</div></td><td><div align='center'>";
	echo $row['Large'];
	echo "</div></td><td><div align='center'>";
	echo $row['XLarge'];
	echo "</div></td><td><div align='center'>";
	echo "<input type='hidden' name='product_name' value='$row['product_name']'>";
	echo "</div></td><td><div align='center'>";
	echo "<form id='edit' action='edit.php' method='post'><input type='submit' name='edit' value='edit'>";
	echo "</div></td><td><div align='center'>";
	echo "<form id='delete' action='delete.php' method='post'><input type='submit' name='product_name' value='remove'>";
	echo "</div></td></tr>";
	}
	
	echo"</table>";

?>

Posted: Thu Nov 30, 2006 9:45 pm
by Burrito
change

Code: Select all

echo "<input type='hidden' name='product_name' value='$row['product_name']'>";
to

Code: Select all

echo "<input type='hidden' name='product_name' value='{$row['product_name']}'>";
you should also add some spaces after your echo statements.

Posted: Thu Nov 30, 2006 9:46 pm
by John Cartwright
you forgot to escape this line

Code: Select all

echo "<input type='hidden' name='product_name' value='".$row['product_name']."'>";
:wink:

Posted: Thu Nov 30, 2006 10:01 pm
by dbdvd7
when i tried both of those, the script runs but everytime I hit the edit button the same variable shows up, even when different variables are clicked. plus an extra empty line is placed at the top of the origanal screen? If anyone can follow what the hell I just wrote god bless you

Posted: Thu Nov 30, 2006 10:04 pm
by Burrito
well your hidden form var isn't inside any form. Also you need to make sure you close your form tags....presently they're not being closed.

Posted: Thu Nov 30, 2006 11:02 pm
by dbdvd7
that helped a lot thanks again