mysql_ deprecated

mysql, php

Solution

According to the `PHP` Manual, you should use any of the following:

- mysqli_stmt_num_rows()

- PDOStatement::rowCount()

To be clear though, neither of these is a mere substitute for `mysql_num_rows()`. Your code must eventually be rewritten entirely to use the MySQLi or PDO API in lieu of `mysql_*()`.

Problem

I have been told that the `mysql_` extension is now deprecated in the current version of PHP and will be removed at some point. What should I use instead of this and how? For nearly all my queries I use it. For example: ``` $result = mysql_query($query); if (!$result) die ("Database access failed: " . mysql_error()); $rows = mysql_num_rows($result); ```

Original source

Related problems