boo_lolly Posted October 19, 2008 Share Posted October 19, 2008 this is really really weird. I've never encountered an error like this before. first here's the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/mysite/functions.php on line 590 Warning: Cannot modify header information - headers already sent by (output started at /var/www/mysite/functions.php:590) in /var/www/dodgecancer/functions.php on line 604 Fatal error: Cannot break/continue 1 level in /var/www/mysite/functions.php on line 605 and here's my code: <?php $sql = ' SELECT * FROM bulletins '; $query = mysql_query($sql) OR die(mysql_error()); while ($row = mysql_fetch_array($query)) { #<----- LINE 590 if ($get_array['ref'] == sha1($row['id'])) { $sql = ' DELETE FROM bulletins WHERE id = '. $row['id'] .' '; $query = mysql_query($sql) OR die(mysql_error()); if ($query) { add_notification('user_panel', 'green', 'Your bulletin post has been deleted.'); } } } header('Location: user_panel.php'); #<-----------------------LINE 604 break; #<----------------------LINE 605 ?> I seriously don't know what to do. I've been trying to test this thing for hours and I cannot understand why it's throwing this error. I've even commented out all processing and just printed the while loop, and everything works... but when I try the above script, it throws the errors. If I can figure out the first error, the other two will go away I'm sure. Here's the weird thing. It gives me this error, right? Then when I press 'Refresh' in the browser, it goes back to the page it's supposed to and shows the correct message. And when I cross reference the database, the correct row has been deleted. So basically, it's working, but throwing an error that doesn't make any sense in the first place... weird right? I need help with this. What's wrong with my syntax or sql statement? Why is it saying there's output when there's clearly NO output? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted October 19, 2008 Share Posted October 19, 2008 The mysql_fetch_array() error is probably because your query is failing. Instead of break; you should have exit; And the header error is because you have outputted html prior to calling the header function. No output can be called before hand. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted October 19, 2008 Author Share Posted October 19, 2008 ProjectFear, As I mentioned in my previous post, the query is working. I've tested it by simply printing out the contents of each $row. I do not get an error when I do that. I am not sending out any output before the header. I have been looking at this problem for over an hour and I need a fresh set of eyes on this. If my sql statement is wrong, WHAT is wrong with it? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 19, 2008 Share Posted October 19, 2008 He is overwriting the $query variable inside of the while loop with a TRUE/FALSE value from the INSERT query, so when the while loop evaluates the condition again, the mysql_fetch_xxxxx instruction fails. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted October 19, 2008 Author Share Posted October 19, 2008 He is overwriting the $query variable inside of the while loop with a TRUE/FALSE value from the INSERT query, so when the while loop evaluates the condition again, the mysql_fetch_xxxxx instruction fails. THAT WAS IT!!! YOU'RE A GENIOUS BRO!!!! Thank you SO much!!!! 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.