psychowolvesbane Posted January 6, 2008 Share Posted January 6, 2008 I have this script: <?php $conn = mysql_connect('$host','$username','$password'); $db = mysql_select_db('$dbname', $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $X=0; while($row = mysql_fetch_array($rs)) { echo"<option value='$X'>$row['ItemType']</option>"; (Line 55) $X=$X+1; } mysql_close($conn); ?> I get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/psychowolvesbane.freehostia.com/admin/add_product_form.php on line 55 Can anyone tell me how i am echoing wrongly on Line 55? P.S. I already have the open and close tags for the Select list form item, just on the outside of this code. Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/ Share on other sites More sharing options...
trq Posted January 6, 2008 Share Posted January 6, 2008 <?php $conn = mysql_connect('$host','$username','$password'); $db = mysql_select_db('$dbname', $conn); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $X=0; while($row = mysql_fetch_array($rs)) { echo "<option value='$X'>{$row['ItemType']}</option>"; $X++; } mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/#findComment-431911 Share on other sites More sharing options...
psychowolvesbane Posted January 6, 2008 Author Share Posted January 6, 2008 No, I tried your code and it still came up with the same error, is there non echoing method to try? e.g. ?> <option val...> <?php Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/#findComment-431912 Share on other sites More sharing options...
Ken2k7 Posted January 6, 2008 Share Posted January 6, 2008 <?php $conn = mysql_connect('$host','$username','$password') or die(mysql_error()); $db = mysql_select_db('$dbname', $conn) or die(mysql_error()); $sql = "SELECT ItemType FROM ItemType ORDER BY ItemType"; $rs = mysql_query($sql, $conn) or die(mysql_error()); $X=0; while($row = mysql_fetch_assoc($rs)) { echo"<option value='$X'>{$row['ItemType']}</option>"; $X=$X+1; } mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/#findComment-431914 Share on other sites More sharing options...
wildteen88 Posted January 6, 2008 Share Posted January 6, 2008 There is no errors with the code thorpe provided. The error must be coming from somewhere else within your code. Can you post lines 45 - 60 here from add_product_form.php Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/#findComment-431917 Share on other sites More sharing options...
psychowolvesbane Posted January 6, 2008 Author Share Posted January 6, 2008 Nevermind I got it using that code, just missed out the connect DB while copying codes around. Link to comment https://forums.phpfreaks.com/topic/84757-solved-small-syntax-problem/#findComment-431921 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.