Jump to content

Query empty, but not if i run it through mysql!!


essjay_d12

Recommended Posts

Here is my code the sql produces results if i run it through MySQL, but now implemented in php it returns a message ... Query empty

[code]
//open connection
$conn = mysql_connect("localhost", "admin", "adm1n");
mysql_select_db("links",$conn);
$sql = "SELECT `c_id`, `name`, `p_id` from `navtest` WHERE `p_id` = 0";

$result = mysql_query($query) or die(mysql_error());
$num = mysql_num_rows($result);

echo '<form action="../admin/InsertLink2.php" method="post">';

if ($num > 0){
      echo '<select name="subject">';
while ($row = mysql_fetch_array($result)){
$c_id = ($row['c_id']);
$name = ($name['name']);

echo $c_id;
echo $name;
echo '<option value="';
echo $c_id;
echo '">';
echo $name;
echo '</option>';
}

}
echo '</select>';
echo '<input name="Submit" type="submit" id="Submit" value="Update" onclick="disp_confirm()" /></form>';
[/code]
In addition to what was mentioned above, it looks like you're referencing the wrong variable for your $name assignment. I think you're probably intending to pull $row['name'] into that variable instead of $name['name']. Your query should return the exact same results through PHP as it does in your admin panel.

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.