PDA

View Full Version : "Unable to save result set" Error


user55
07-31-2007, 07:50 PM
Hi,

I keep getting the following error. What is causing this error? Any help would be appreciated.

Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/mysite/public_html/demo.php on line 303
Invalid query

That error is this line, which you can see at the bottom of the code below:

$result = mysql_query($sql) or die("Invalid query") . mysql_error();

Here is the PHP Code:


$sql .= "SELECT
audit.id,
audit.month,
audit.monthlyamount,
jmas.id,
jmas.year,
jmas.productid,
quarter.id,
quarter.qamount,
quarter.company";
$sql .= "FROM
audit audit,
jmaster jmaster,
quarter quarter";
if ($currentrow_sql != "") {
$sql .= "WHERE
audit.id = jmas.id AND jmas.id = quarter.id AND .$currentrow_sql";
}
$result = mysql_query($sql) or die("Invalid query") . mysql_error();
$row = mysql_fetch_array($result);
}



___________________

Sara

guelphdad
07-31-2007, 08:21 PM
one small thing first, you don't need to give a column an alias if you aren't renaming it, same with a table so you don't need:

audit audit,
jmaster jmaster,
quarter quarter

but just

audit,
jmaster,
quarter


now to your problem. Echo out $result and see what it tells you. I'm not sure where $currentrow_sql is set, is this coming from earlier in your script?

for instance if the value of currentrow_sql is 7 for instance your query would be

audit.id = jmas.id AND jmas.id = quarter.id AND 7


doesn't make a lot of sense now does it?