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.

posted on 25.01.2020 at 19:15
0pnshow more
onefiveonefive
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) ) {

}
posted on 26.01.2020 at 17:52
0pnshow more
TimTim
share on facebookshare on twitter
2021 AnswerTabsTermsContact us