Jump to content

unexpected T_STRING


Recommended Posts

Youve got your quotes all mixed up.

echo "<B>Small:</B> '.$content['sizes'].'";

Should be

echo '<B>Small:</B> '.$content['sizes'];

with that type of concat or use double quotes to concat

echo "<B>Small:</B> ".$content['sizes'];

Or you can use interpolation

echo "<B>Small:</B> {$content['sizes']}";

Link to comment
https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277397
Share on other sites

Yep, thats the exact code I used from the start. I suspect the error is else where:

 

 

<?php
	session_start();
if (empty($_SESSION['cart']['content'])) {
	echo '<DIV class="nocart">No product in cart.</DIV>';
}
else {
	echo '	<DIV class="cartcontent">';
		$link = mysql_connect('localhost', 'testusr', 'testpw');
		mysql_select_db('testdb', $link);
		foreach ($_SESSION['cart']['content'] as $content) {
		$query = "select * from products where id='{$content['id']}'"; $result = mysql_query($query); $row = mysql_fetch_array($result);
		echo '
			<DIV class="cartproduct">
				<DIV class="productdescriptor">
					'.$row['id'].'
					<BR>
					<IMG alt="" class="thumbnail" src="../products/'.$row['fordir'].'/'.$row['categorydir'].'/'.$row['id'].'/thumbnail.png">
				</DIV>
				<DIV class="cartproductdata">
		';
	';
					if ($content['sizes'] == 0) {goto sizem;} else {echo "<B>Small:</B> ".$content['sizes'];}
					echo "<BR>";
					sizem:
					if ($content['sizem'] == 0) {goto sizel;} else {echo "<B>Medium:</B> ".$content['sizem'];}
					echo "<BR>";
					sizel:
					if ($content['sizel'] == 0) {goto sizexl;} else {echo "<B>Large:</B> ".$content['sizel'];}
					echo "<BR>";
					sizexl:
					if ($content['sizexl'] == 0) {goto endsizes;} else {echo "<B>Extra large:</B> ".$content['sizexl'];}
					echo "<BR>";
					endsizes:
					echo '	<BR>
						<BR>
						<B>Unit price:</B> $'.$row[price].' AUD
						<BR>
						<BR>
						<INPUT type="submit" value="REMOVE FROM CART">
				</DIV>
			</DIV>
		';
		$sizestotal = $content['sizes'] * $row['price'];
		$sizeltotal = $content['sizel'] * $row['price'];
		$idtotal = $sizestotal + $sizeltotal;
		$total = $idtotal;
	}
	echo "	</DIV>";
	mysql_query ($query);
	mysql_close($link);
	echo '
		<DIV class="totalandproceed">
			Total: $'.$total.'
			<BR>
			<INPUT type="submit" value="PROCEED TO PAYMENT">
		</DIV>
	';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277408
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.