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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.