Page 1 of 1

supplied argument is not a valid MySQL-Link resource

Posted: Tue Jan 21, 2003 12:30 pm
by kendall
Hi,

I have the following code that connects to a database and updates an item in a record -

require_once('Connections/CLIENT_DATABASE.php');
$QUERY = "UPDATE website_info SET Pass ='".$_POST['Password']."' WHERE WebID ='".$_POST['ID']."'";
$INFO = QUERY_DATA($QUERY,$database_CLIENT_DATABASE,$CLIENT_DATABASE); // function in CLIENT_DATABASE file
$updated = mysql_affected_rows($INFO);
$results = mysql_fetch_row($INFO);
header('Location: acc_info.php');
exit;

on executing this script i get

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource
Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource

Now what i can't get is that although i get these errors the record is updated never the less.

even did it through mysql client and i got an error free output.

Now im thinking maybe its because of the way i have it required from a function. But i have this coding in another script which does it with out error. probably only difference is it SELECTS

Now my question is if its updating the record y am i getting the error

Posted: Tue Jan 21, 2003 12:50 pm
by twigletmac
What does the QUERY_DATA() function look like?

Mac

Posted: Tue Jan 21, 2003 12:58 pm
by kendall
It looks like:-

function QUERY_DATA($QUERY,$database_CLIENT_DATABASE,$CLIENT_DATABASE){
mysql_select_db($database_CLIENT_DATABASE, $CLIENT_DATABASE);
$RESULTS = mysql_query($QUERY,$CLIENT_DATABASE) or die(mysql_error());
return $RESULTS;
}

supplied argument is not a valid MySQL-Link resource

Posted: Tue Jan 21, 2003 1:31 pm
by kendall
AAAH,

i think i figured out my answer

in my notes i see that in a UPDATE or INSERT the mysql_fetch... isn't being used to get results. YOU CAN'T after an update statement there no results to get and instead you use rows_affected as something to use for results

YES
i think thats it, does anyone care to differ?

No $result

Posted: Thu Jan 23, 2003 10:15 am
by bchino
mysql_query() does not return a $result when the query is a 'UPDATE', 'INSERT', or 'DELETE';
As such, you can even freely code it as
mysql_query($query);
- instead of -
$result = mysql_query($query);