Sabmin Posted December 23, 2010 Share Posted December 23, 2010 This is really blowing my mind... the code is as follows the table, the column names everything is right and contains information but the variables aren't being filled... I don't get it... Anyone have any ideas or options I might not have thought of for debugging? $item_name = ("SELECT * FROM items WHERE id = '$grab_item'"); $que_items = mysql_query($item_name); while ($item_todel = mysql_fetch_array($que_items, MYSQL_BOTH)) { $name = $item_todel['name']; $desc = $item_todel['desc']; } echo ($name . "<br>" . $desc . "<br>" . $grab_item); the only variable thats set is grab_item, fetch_array throws no errors, if I plug in the query straight to the sql I get all the proper information... It's just not filling the two variables.... Quote Link to comment https://forums.phpfreaks.com/topic/222461-rogue-while-loop-not-filling-variables-from-sql-fetch-array/ Share on other sites More sharing options...
trq Posted December 23, 2010 Share Posted December 23, 2010 Anyone have any ideas or options I might not have thought of for debugging? Not hard considering there is no error trapping / debugging in your code at all. Are you expecting more than one result? If so, you will need to do the echo'ing within the while loop. If your not, then you don't even need a while loop. $sql = "SELECT name, `desc` FROM items WHERE id = '$grab_item'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { $name = $row['name']; $desc = $row['desc']; echo $name . "<br>" . $desc . "<br>" . $grab_item; } } else { echo "No results found"; } } else { trigger_error(mysql_error() . "<br />$sql"); } Quote Link to comment https://forums.phpfreaks.com/topic/222461-rogue-while-loop-not-filling-variables-from-sql-fetch-array/#findComment-1150625 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.