Search code examples
mysqlload-data-infilephp-iniphp

Could not connect to my sql using php ,undefined function mysql_connect()


i want to open a connection to mysql database using php with following code:

$connection= mysql_connect("localhost","m****","******");

but I've got undefined function mysql_connect()

i checked out my phpinfo() and got this: phpinfo()

so i tried to turn on mysqli.allow_local_infile so i do following in php.ini file: mysqli.allow_local_infile = On

and tried to restart apache2 and mysql services but does not effect.

what should i do? thanks in advance,

I'm using Ubuntu 18.4 with php 7.2.24 and mysql Ver 14.14 Distrib 5.7.28


Solution

  • You need to change your function name from mysql_connect to mysqli_connect as mysql_ is not supported in PHP7.x

    further, you need to use all functions having mysqli_ instead of mysql_

    For more guidance: https://www.php.net/manual/en/book.mysqli.php