thanks!...my fault... I had never used it...been using mysql_num_rows so that is where I took the example.
Thanks! Eddie -----Original Message----- From: Kevin Stone [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 04, 2003 4:53 PM To: Edward Peloke; [EMAIL PROTECTED] Subject: Re: [PHP] testing a query for success--code doesnt work FYI unlike the other mysql result functions mysql_affected_rows() works on the last query *only* and does not accept a results pointer as input. So this will result in an error... $result = mysql_query("UPDATE.. whatever"); $affected_rows = mysql_affected_rows($result); //<== invalid identifier Simply leave the $result out of the function... $result = mysql_query("UPDATE.. whatever") or die("Invalid query."); $affected_rows = mysql_affected_rows(); if ($affected_rows == 0) echo "<font color=red>The query ran but no rows were updated.</font>"; else echo "<font color=green>".$affected_rows." were updated.</font>"; -Kevin ----- Original Message ----- From: "Edward Peloke" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 04, 2003 2:16 PM Subject: RE: [PHP] testing a query for success--code doesnt work > Just grab your qu > > <? > $affected_rows = mysql_affected_rows($query); > if ($affected_rows==0){ > print "No rows updated"; > } > else{ > print $affected_rows." rows have beenupdated."; > } > > ?> > or something along those lines...but also add in your check to see if the > query ran without errors. > > Eddie > > > -----Original Message----- > From: Sunfire [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 04, 2003 4:03 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] testing a query for success--code doesnt work > > > yes that is what i needed.. how many rows were changed as well as how did > the query run in general... i want the: > if($query){ > ok message > } > else{ > fail message > } > but i also want a query test that goes something like this: > if(0 rows were updated){ > message saying nothing happened > }else{ > message saying the record was actually updated > } > if i can get some code example for that...it would help > > tnx > > ----- Original Message ----- > From: "Edward Peloke" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, February 04, 2003 3:46 PM > Subject: RE: [PHP] testing a query for success--code doesnt work > > > > I believe as long as the update was successful (no errors) it will say > > 'message if successful'...I think you are wanting to know if rows were > > updated or not...not whether or not the query ran ok. > > > > Eddie > > > > -----Original Message----- > > From: Sunfire [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, February 04, 2003 3:51 PM > > To: [EMAIL PROTECTED] > > Subject: [PHP] testing a query for success--code doesnt work > > > > > > hi.. > > posted a message about what the code was to test an update query to see if > > it was successfull using mysql and i tested my code and for some reason > even > > if none of the fields were updated it still reports the success message... > > > > heres the code i have: > > $query=mysql_query("update members set company="\$company\", ........); > > if($query){ > > message if successfull... > > } > > else{ > > message if not or if failed..//never gets used > > } > > anybody know why this doesnt work if 0 records were changed? > > > > > > > > --- > > Outgoing mail is certified Virus Free. > > Checked by AVG anti-virus system (http://www.grisoft.com). > > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.443 / Virus Database: 248 - Release Date: 1/10/2003 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php