1

I read that mysql_num_rows is deprecated as of PHP 5.5.0, and will be removed in the future. So what is best replacement by your opinion?

$KatalogVrstaID = $redak_katalog['KatalogVrstaID'];
$rezultat_podvrsta=mysql_query("SELECT * FROM katalog_podvrsta WHERE KatalogPodvrstaVrsta='$KatalogVrstaID' ORDER BY KatalogPodvrstaID ASC");
if (mysql_num_rows($rezultat_podvrsta)==0){ ?>  
1
  • 3
    You should first change mysql_* functions to mysqli or PDO. Because the whole mysql_* functions will be deprecated in the coming versions. Commented Dec 5, 2013 at 10:03

5 Answers 5

1

The mysql functions as a whole are deprecated, it is not only mysql_num_rows. You should switch to mysqli or POD database library. In short all mysql_* functions are deprecated.

You can read more about picking a database API here.

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

Comments

1

Mysqli is the new library you should use. they use the same function names but instead of mysql you write mysqli.. you also need to add one more parameter which is the link.

Comments

1

mysql extension is deprecated as of PHP 5.5.0. Instead, either the mysqli or PDO_MySQL extension should be used https://www.php.net/class.mysqli

Comments

1

The only replacement is to stop using mysql_* altogether, because the whole library is deprecated.

PDO provides PDOStatement::rowCount() which you use on result objects, and MySQLi provides mysqli_result::$num_rows or mysqli_num_rows().

Comments

1

1) Use MySQLi / PDO, like the Authors above me said. 2) I read in a book that rowCount() is not 100% reliable for Select statements in some DBMS, but their are alternatives to count all rows

a) use fetchAll() <- not recommend for large results. b) use COUNT(*) in the Select-Statement and work with the result.

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.