darklight Posted October 1, 2009 Share Posted October 1, 2009 I keep getting this error, I been trying to fix it for like 24 hours now. I really can't seem to do it. Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/content/d/a/r/darklight188/html/chat/server.php on line 42 $sql = "INSERT INTO `chat` VALUES('','$message','".time()."','$id')"; mysql_query($sql); } $sql = "SELECT `Text` FROM `chat` WHERE `chatid`='$id' ORDER BY `Id` DESC"; $result = mysql_query($sql); while($row = mysql_fetch_row($result)) { echo($row['Text']."<br>"); } Line 42: while($row = mysql_fetch_row($result)) { Link to comment https://forums.phpfreaks.com/topic/176217-php-sql-query-help/ Share on other sites More sharing options...
Maq Posted October 1, 2009 Share Posted October 1, 2009 Your query is probably failing. Echo out $sql and mysql_error() to help diagnose the problem. Link to comment https://forums.phpfreaks.com/topic/176217-php-sql-query-help/#findComment-928675 Share on other sites More sharing options...
cags Posted October 1, 2009 Share Posted October 1, 2009 The error means that the value returned by mysql_query is invalid, ie meaning your query failed. The most likely reasons are... Your not connected to a database The table name doesn't exist One or more of the field names doesn't exist A value your trying to install is invald. <?php echo $sql; $result = mysql_query($sql) or die(mysql_error); // or $result = mysql_query($sql) or trigger_error(mysql_error, E_USER_ERROR); // should give you an idea which ?> Edit: Beaten to it again Link to comment https://forums.phpfreaks.com/topic/176217-php-sql-query-help/#findComment-928677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.