0

My test code:

    $connection = mysql_connect('localhost', 'root', '') or die(mysql_error());

    mysql_select_db("chaoge", $connection);

    mysql_query("SET NAMES UTF8", $connection);

    $rs = mysql_query("SELECT * FROM babel_node WHERE nod_pid = 2101", $connection);

    $nu = mysql_affected_rows();
    echo $nu;

It says that mysql_affected_rows works with INSERT, UPDATE, REPLACE and DELETE。

Why I can also get the right result through mysql_affected_rows ?

Any help and suggestions will be highly appreciable。

2 Answers 2

0

Here is what I found on the internet.

mysql_affected_rows() for a SELECT indicates the number of rows which were found. mysql_num_rows() indicates how many rows were actually returned. They may not be the same, IIRC, if you have a LIMIT clause or similar. GROUP BY may also cause a difference.

Source

See answers on the source at the bottom.

1
  • Thank you very much . Very helpful to me
    – tripleCC
    Sep 24, 2015 at 9:42
0

I suggest you must use

MySQLi http://php.net/manual/en/book.mysqli.php

or

PDO_MySQL http://php.net/manual/en/ref.pdo-mysql.php

for updated method of accessing database since your method was deprecated in PHP 5.5.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.