I work with the database in this way:

<?php $page = $_GET["page"]; mysql_connect("localhost", "login", "password") or die(mysql_error()); mysql_select_db("aqqBD") or die(mysql_error()); $strSQL = "SELECT * FROM mydatabase LIMIT ".$page.",3"; $rs = mysql_query($strSQL); while($row = mysql_fetch_array($rs)) { echo $row['state']." - ".$row['date']." - ".$row['id']."<br>"; } mysql_close(); 

Everything is fine, but such an error constantly hangs in error_log , how can I fix it?

PHP Deprecated: mysql_connect (): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in ...

If I start using mysqli_connect , then an error occurs with mysql_select_db

  • 3
    go to the docks php.net/manual/ru/function.mysql-connect.php and read the inscription on a red background with the words Attention . And for mysqli, methods are used that start with mysqli_ , and not mysql - Alexey Shimansky

1 answer 1

In recent versions of PHP, it's time to abandon mysql and switch to mysqli. They hint to you:

use mysqli or PDO

If you use mysqli_connect , then use and mysqli_select_db , not mysql_select_db