Jump to content

PHP SQL Query Help!


darklight

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.