WendyLady Posted June 11, 2006 Share Posted June 11, 2006 Hi everyone --I have an interesting thing happening that is just annoying, but interesting. I can work around it, but I would really like to know why it is happening.I have an option on a form that either UPDATEs or DELETEs a row in the MySQL database. After each one, I have the following code to confirm the UPDATE or DELETE:[code]if (mysql_affected_rows != 1) { echo 'Problem!'; echo '<br />' . mysql_affected_rows() . $query; }else{ header ("Location: index.php"); }[/code]The screwy thing is, for the UPDATE query it returns "Problem! 1 (affected row)" and then the query. And when I check the database, it [b]has updated properly[/b].For the DELETE query, it returns "Problem! 0 (affected rows)" and then the query. And when I check the database, it [b]has deleted properly[/b].Why would it be going into the "if !=1" when it IS equal to 1, and why would it be returning 0 affected rows when there IS an affected row? I have stated the above in a variety of ways, such as reversing it to "if ==1", "if ==0 || if == -1", etc., to no avail!Have you seen this before? Am I making a stupid mistake that is causing it?Darn curious (and Thank you!),Wendy Quote Link to comment https://forums.phpfreaks.com/topic/11748-screwy-mysql_affected_rows-problem/ Share on other sites More sharing options...
AndyB Posted June 11, 2006 Share Posted June 11, 2006 mysql_affected_rows is meaningless - either it's a function and you forgot the parentheses [see below], or you intended it as a variable and it needed a $ ... How about this:[code]if (mysql_affected_rows() != 1) { [/code] Quote Link to comment https://forums.phpfreaks.com/topic/11748-screwy-mysql_affected_rows-problem/#findComment-44447 Share on other sites More sharing options...
WendyLady Posted June 11, 2006 Author Share Posted June 11, 2006 Well, shoot. I think I've been working on it too long. I just advised someone else to take a break, and now I think it is time for me to do so, too.LOL -- thank you!Wendy Quote Link to comment https://forums.phpfreaks.com/topic/11748-screwy-mysql_affected_rows-problem/#findComment-44451 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.