Freedom-n-Democrazy Posted October 9, 2011 Share Posted October 9, 2011 What is a T_STRING? google.com cannot find anything about it in the PHP manual. ... and, why am I getting "unexpected T_STRING" for this line? if ($content['sizes'] == 0) {goto sizem;} else {echo "<B>Small:</B> '.$content['sizes'].'";} Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/ Share on other sites More sharing options...
Buddski Posted October 9, 2011 Share Posted October 9, 2011 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']}"; Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277397 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 Hey Buddski, Not one of those lines worked - still getting the same error. Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277404 Share on other sites More sharing options...
MasterACE14 Posted October 9, 2011 Share Posted October 9, 2011 if ($content['sizes'] == 0) { goto sizem; } else { echo "<B>Small:</B> ".$content['sizes']; } Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277405 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 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> '; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277408 Share on other sites More sharing options...
Freedom-n-Democrazy Posted October 9, 2011 Author Share Posted October 9, 2011 Mistake detected! There was an extra '; that should not have been there. Quote Link to comment https://forums.phpfreaks.com/topic/248733-unexpected-t_string/#findComment-1277409 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.