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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much . Very helpful to me
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

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.