T_ENCAPSED_AND_WHITESPACE error?

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
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

T_ENCAPSED_AND_WHITESPACE error?

Post 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>";

?>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you forgot to escape this line

Code: Select all

echo "<input type='hidden' name='product_name' value='".$row['product_name']."'>";
:wink:
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

Post by dbdvd7 »

that helped a lot thanks again
Post Reply