Page 1 of 1

unknown php-mysql UPDATE error :/

Posted: Sat May 17, 2003 4:42 pm
by Coco
weird little problem here :/
im trying to do an update, the query is:

Code: Select all

UPDATE users SET reg_date = reg_date, rate_num = rate_num + 1, rate_sum = rate_sum + 5 WHERE id = '920c13683f0c4ca048b68640f3ec1078'
Now ive phpmyadmin open at the same time, and ive tried that exact same query in phpm.a. and it worked

but when i run it in php i get
UPDATE users SET reg_date = reg_date, rate_num = rate_num + 1, rate_sum = rate_sum + 5 WHERE id = '920c13683f0c4ca048b68640f3ec1078'
Warning: Supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/uo-auction2.com/httpdocs/bfeedback.php on line 169
Abnormal database error.
The php is:

Code: Select all

<?php
$query5 = 'UPDATE ' . $tableusers . ' SET reg_date = reg_date, rate_num = rate_num + 1, rate_sum = rate_sum + ' . $HTTP_POST_VARS[rate] . " WHERE id = '" . $target . "'";
$result5 = mysql_query($query5);
echo $query5;
if(mysql_num_rows($result5)<1)//line 169
{
	echo 'Abnormal database error.<br>' . mysql_error();
	exit;
}
?>
Can someone please put me out of my misery and tell me why a query that works in phpmyadmin doesnt work in php itself :(

Posted: Sat May 17, 2003 7:28 pm
by CONFIQ
Try this to see mysql_error
$result5 = mysql_query($query5) or die(mysql_error());

Posted: Sat May 17, 2003 8:12 pm
by Coco
i already have mysql_error inside the if loop... and it returned no error

Posted: Sat May 17, 2003 10:03 pm
by evilcoder
that error usually means that there is a field which doesnt exist, or you've misspelt it.

Posted: Sun May 18, 2003 6:54 am
by Coco
if you read again, you will see that i cut and pasted EXACTLY the same query into phpmyadmin and it worked

Posted: Sun May 18, 2003 7:03 am
by twigletmac
Perhaps mysql_error() is returning nothing because it's being called after mysql_num_rows() and:
PHP manual wrote:this function only returns the error text from the most recently executed MySQL function
It would be a good idea to add an or die() statement with mysql_error() (as CONFIQ suggested) to see if there is an error being returned by mysql_query().

You have connected to MySQL and selected the required database and that's not thrown any errors?

Mac

Posted: Sun May 18, 2003 7:35 am
by Coco
It still doesnt give an error
i changed it to

Code: Select all

<?php
//--
$result5 = mysql_query($query5);
echo $query5 . ' ' . mysql_error();
//--
?>
And theres still no error output
theres about 6 queries before this one so its not a connection error