harrishcris Posted March 13, 2006 Share Posted March 13, 2006 Hello, I have this script for processing my shoutbox, however it comes up with this error when i click submit: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/oltvkwrk/public_html/Changeable/Rightside.php on line 104 and row 104 is:// button has been submited so processs data $result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 1"); [b]while ($row = mysql_fetch_row($result)) {[/b] if ($row[2] != $message) {Here is my full code...[code]// Delte shoutbox row if over 100$result = mysql_query("SELECT * FROM shoutbox");$max_shouts = 100;if (mysql_num_rows($result) > $max_shouts){ while (mysql_num_rows($result) > $max_shouts){ $get_last_row = mysql_query("SELECT * FROM shoutbox ORDER BY id asc limit 1"); while ($row = mysql_fetch_row($get_last_row)){ $delete_row = mysql_query("DELETE FROM shoutbox WHERE id=$row[0]"); $result = mysql_query("SELECT * FROM shoutbox"); } }} ?> </span> <?if (empty($message)) {$message = "No message left.";}if (empty($name)) {$name = "Anonymous";}if (isset($_POST['submit'])){// button has been submited so processs data $result = mysql_query("SELECT * FROM shoutbox ORDER BY id DESC LIMIT 1"); while ($row = mysql_fetch_row($result)) { if ($row[2] != $message) { // assign the ip$ip = $_SERVER['REMOTE_ADDR']; // inserting it into the shoutbox table which we made in the mysql statements before$result = mysql_query("INSERT INTO shoutbox (id,name,message,ip) VALUES ('NULL','$name', '$message', '$ip')");}}}//returning the last 5 messages$result = mysql_query("SELECT * FROM shoutbox order by id desc limit 10");//the while loopwhile($r=mysql_fetch_array($result)){ //getting each variable from the table $id=$r["id"]; $message=$r["message"]; $name=$r["name"];?>[/code]Any ideas??Cheers, Chris Quote Link to comment Share on other sites More sharing options...
harrishcris Posted March 13, 2006 Author Share Posted March 13, 2006 Also, the shoutbox does actually work, even though the error comes up, it still saves the info to the database... Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted March 13, 2006 Share Posted March 13, 2006 change this:[code]$get_last_row = mysql_query("SELECT * FROM shoutbox ORDER BY id asc limit 1");[/code]to this[code]$get_last_row = mysql_query("SELECT * FROM shoutbox ORDER BY id asc limit 1") or die(mysql_error());[/code]it won't solve your problem, but will tell you what the problem may be. the above line is failing you somewherecheers Quote Link to comment Share on other sites More sharing options...
keeB Posted March 13, 2006 Share Posted March 13, 2006 It means there's a problem with one of your query's.What I do to troubleshoot this all the time, is [code]$q = "select * from some table";if ($debug) print $q;[/code]If I ever want to check some debug information, I just throw a [i]$debug = true[/i] on top of the file somewhere.. and the whole page shows my debug information [=This is a very quick way to troubleshoot SQL queries and whatnot.. Hope that makes sense [=.. Once you know that all the queries can be run properly with correct data, then you'll know you need to look elsewhere.. like making sure the connection is made and whatnot!Good luck! Quote Link to comment Share on other sites More sharing options...
harrishcris Posted March 13, 2006 Author Share Posted March 13, 2006 No, my query is fine... the code works fine and it adds the shout into the database, but it comes up with the error message... Quote Link to comment Share on other sites More sharing options...
keeB Posted March 13, 2006 Share Posted March 13, 2006 [!--quoteo(post=354654:date=Mar 13 2006, 09:03 PM:name=harrishcris)--][div class=\'quotetop\']QUOTE(harrishcris @ Mar 13 2006, 09:03 PM) [snapback]354654[/snapback][/div][div class=\'quotemain\'][!--quotec--]No, my query is fine... the code works fine and it adds the shout into the database, but it comes up with the error message...[/quote]Yep.. normally when everything works fine for me I get an error message as well.. Quote Link to comment Share on other sites More sharing options...
harrishcris Posted March 14, 2006 Author Share Posted March 14, 2006 So does anyone have a solution or know a different way of achieving what i want to do...??? 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.