Maybe I have the overall logic wrong. I don't do a select query first to see if that record is there. I just try to update it.
If the logonid key in the update request is on the table, the record does get updated. I can verify that using phpmyadmin. When the logonid key in the update request is not on the table, the results checks still take the record successful updated condition. A look at the table using phpmyadmin shows me that there is no record matching that logonid key. My last test I tried this if ($results == TRUE) and still the update was successful condition is taken even when the update key value is not on the table. I would expect the update was unsuccessful condition to have been taken. So the basic question boils down to why does the successful condition always get taken even when there is no match on the table for the key value being used? This is testing a new developed script, so there may be a logic error in how things are done in the script. But I need to have the results of the update to be able to tell difference between a good update and one where the key used to target the record is not on the table. How do you suggest I should code the result condition test? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Sunday, March 12, 2006 5:20 PM To: mysql@lists.mysql.com Subject: Re: Checking for good update Maybe I need to read the copy of php pocket reference I have to David - LOL. Keith On Sun, 12 Mar 2006 [EMAIL PROTECTED] wrote: > To: mysql@lists.mysql.com > From: [EMAIL PROTECTED] > Subject: Re: Checking for good update > > > looks a bit strange to me. > > > $result = mysql_query($query) or die('Query couldn\'t > > executed:'.mysql_error()); > > please try something like this: > > // build the query - (that's OK) > $query = "UPDATE members SET email_verified='X' WHERE > logon_id='" .$logonid. "'"; > > // send the query to the server - save the result resource > $res = mysql_query($query); > > // test for the result of the above query > if(!$res) > { > // stop the script if the result is not valid > die('Query couldn\'t be executed:'.mysql_error()); > } > > // process a valid result > $row = mysql_fetch_array($res) > > if (mysql_num_rows($res) == 1) > { > // the user id and password match, > print("User id on db"); > } > else > { > //$errorMessage = 'Sorry, wrong user id / password'; > print("Sorry, wrong user id / password"); > } > > I've not tested this - but it looks like you are mixing sending the > mysql query and testing for the result of the query at the same time, > which AFAIK is not possible. > > Maybe you need to get a simple introductory book on php, such as O'reillys > php pocket reference, ISBN 0596-00402-8. > > Regards > > Keith > > In theory, theory and practice are the same; > In practice they are not. > > On Sun, 12 Mar 2006, fbsd_user wrote: > > > To: Mysql <mysql@lists.mysql.com> > > From: fbsd_user <[EMAIL PROTECTED]> > > Subject: Checking for good update > > > > Using this code I get this error message. > > > > Warning: mysql_num_rows(): supplied argument is not a valid MySQL > > result resource in /usr/local/www/data/mls_verifyemail.php on line > > Probably because you are not sending a valid query to the server, > you will not be getting a valid result resource back from the server. > > > What code should I use to check if the update worked or not? > > > > > > $query = "UPDATE members SET email_verified='X' WHERE > > logon_id='".$logonid."'"; > > > > $result = mysql_query($query) or die('Query couldn\'t > > executed:'.mysql_error()); > > > > if (mysql_num_rows($result) == 1) > > { > > // the user id and password match, > > print("User id on db"); > > } > > else > > { > > //$errorMessage = 'Sorry, wrong user id / password'; > > print("Sorry, wrong user id / password"); > > } > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]