Jump to content

[SOLVED] Small syntax problem


psychowolvesbane

Recommended Posts

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

<?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);
?>

<?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);
?>

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.