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.

0
give a positive ratinggive a negative rating
25 Jan 2020 at 07:15 PM
Hi,

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) ) {

}
0
give a positive ratinggive a negative rating
26 Jan 2020 at 05:52 PM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us