Fatal error: Call to undefined function mysql_connect()

SQL

I have set up PHP, MySQL, and Apache. localhost() for PHP and it is working well. But after I downloaded MySQL, it reports:

Fatal error: Call to undefined function mysql_connect()

 

How can I fix this?

 


If you want to unleash your potential in this competitive field, please visit the SQL course page for more information, where you can find the SQL tutorials and SQL frequently asked interview questions and answers as well.

1
Answers

Replies

In the latest version of PHP 7, the mysql_connect is deprecated. You can check out the version using the below statement.


hp -version


 


You will need to change to mysqli_connect as:



$host = "127.0.0.1";


$username = "root";


$pass = "foobar";


$con = mysqli_connect($host, $username, $pass, "your_database");

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top