essjay_d12 Posted January 24, 2007 Share Posted January 24, 2007 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] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 24, 2007 Share Posted January 24, 2007 $sql = "SELECT `c_id`, `name`, `p_id` from `navtest` WHERE `p_id` = 0";$result = mysql_query($query) or die(mysql_error());you're using two variables, $sql and $query. Pick one ;) Quote Link to comment Share on other sites More sharing options...
obsidian Posted January 24, 2007 Share Posted January 24, 2007 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. Quote Link to comment Share on other sites More sharing options...
essjay_d12 Posted January 24, 2007 Author Share Posted January 24, 2007 Thanks , both solved my problems Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.