Fatal error: Call to undefined function mysql_query() - PHP

On my new hosting, when I try to get the data from MySQL database with SELECT statement, the following error notification appears:

Fatal error: Uncaught Error: Call to undefined function mysql_query()

Can you please give me suggestion how can I fix it ? On other hosting I use, the error notification doesn't appear in case of the same source code.

25 Jan 2020 at 07:15 PM
0pnshow more

To execute a query on a MySQL database, try to use function mysqli_query() instead of mysql_query(). The source code for mysqli_query() should look like:

$connection = mysqli_connect("localhost", "username", "password", "database");

if ( $result = mysqli_query($connection, $query) ) {

26 Jan 2020 at 05:52 PM
0pnshow more
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us