error in taking table data into listbox

Discussion in 'PHP' started by kharearch, Jan 24, 2008.

  1. #1
    I am trying to insert table data into listbox. It is giving following error.

    Parse error: syntax error, unexpected T_STRING in /home/sanganak/public_html/rajiv2/listbox_category.php on line 23

    My code is this -

    <body>
    <?php
    $con = mysql_connect("localhost","sanganak_manish","manish");

    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }mysql_select_db("sanganak_mydata",$con);
    $result = mysql_query("SELECT * FROM category);
    ?>

    ERROR <p align="center" class="style1">Edit/Delete Category </p>
    <table width="100%" border="0">
    <form method="post" action="edit_delete_category.php">
    <tr>
    <td width="12%">&nbsp;</td>
    <td width="26%">Name of Category </td>
    <td width="14%">

    <?php
    echo '<select name="category">';
    while($row = mysql_fetch_array($result))
    {
    echo "<option value='".$row['category']."'>'."$row['category']".'</option> ";
    }
    echo "</select>";?>
    ?>

    </td>
    <td width="36%"><input name="edit" type="submit" id="edit" value="Edit"> <input name="delete" type="submit" id="delete" value="Delete"></td>
    <td width="6%">&nbsp;</td>
    <td width="6%">&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </form>
    </table>
    <p align="center" class="style1">&nbsp;</p>
    </body>

    Please solve my error.
     
    kharearch, Jan 24, 2008 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    On line 23, replace with this proper syntax

    
    echo "<option value='".$row['category']."'>".$row['category']."</option>";
    
    PHP:
     
    Kaizoku, Jan 24, 2008 IP
  3. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Please take care, error is marked as red in color. Thanks for your kind help.
     
    kharearch, Jan 24, 2008 IP
  4. sharqi

    sharqi Guest

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $result = mysql_query("SELECT * FROM category);

    should be

    $result = mysql_query("SELECT * FROM category");

    The line number is not always correct due to how PHP parses.
     
    sharqi, Jan 24, 2008 IP