Jump to content

Screwy mysql_affected_rows() Problem


WendyLady

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/11748-screwy-mysql_affected_rows-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.