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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.