## Undefined function mysql_connect()

undefined function mysql_connect() xampp
uncaught error: call to undefined function mysql_connect()
call to undefined function mysql_connect() windows
call to undefined function mysql_connect() php 7
call to undefined function mysql_connect() cpanel
0 call to undefined function mysql_connect
call to undefined function mysql_connect in laravel
call to undefined function mysql_select_db()

I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error:

Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21

phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed.

Try checking to see if the PHP MySQL extension module is being loaded:

<?php
phpinfo();
?>


If it's not there, add the following to the php.ini file:

extension=php_mysql.dll


Fatal error: Call to undefined function mysql_connect(), Call to undefined function mysql_connect(). If you are encountering this error, it is probably because you are trying to use the old mysql_* functions in PHP 7. Fatal error: Uncaught Error: Call to undefined function mysql_connect() in F:\xampp\htdocs\try\index.php:17 Stack trace: #0 {main} thrown in F:\xampp\htdocs\try\index.php on line 17 Does it mean that the mysql_connect that I used is not already supported in new xampp ?

I see that you tagged this with Ubuntu. Most likely the MySQL driver (and possibly MySQL) is not installed. Assuming you have SSH or terminal access and sudo permissions, log into the server and run this:

sudo apt-get install mysql-server mysql-client php5-mysql


If the MySQL packages or the php5-mysql package are already installed, this will update them.

UPDATE

Since this answer still gets the occasional click I am going to update it to include PHP 7. PHP 7 requires a different package for MySQL so you will want to use a different argument for the apt-get command.

sudo apt-get install mysql-server mysql-common php7.0 php7.0-mysql


And importantly, mysql_connect() has been deprecated since PHP v5.5.0. Refer the official documentation here: PHP: mysql_connect()

Call to undefined function mysql_connect(), This error is encountered when we try to use “mysql_connect()” functions of php5 in php7. PHP Fatal error: Uncaught Error: Call to undefined  Fatal Error: Uncaught error: Call to undefined function mysql_connect () 1. Use MySQLi or PDO. Instead of using “mysql_connect ()” we should use “mysqli_connect ()” in php7 to avoid this error. 2. Connecting to Mysql with the Pdo Object Is Pretty Straight Forward. 3. Connecting to MySQL with MySqli

In case, you are using PHP7 already, the formerly deprecated functions mysql_* were removed entirely, so you should update your code using the PDO-functions or mysqli_* functions instead.

If that's not possible, as a workaround, I created a small PHP include file, that recreates the old mysql_* functions with mysqli_*()-functions: fix_mysql.inc.php

Call to Undefined Function mysql_connect(), Fatal error: Call to undefined function mysql_connect() in C:\Drupal\drupal-4.6.2\​includes\database.mysql.inc on line 31. this msg came out. In short, php fatal error call to undefined function mysql_connect () error occurs after PHP version upgrade. This is due to the removal of the mysql_connect function from PHP 7+ versions. Today, we saw how our Support Engineers fixed the PHP fatal errors. PREVENT YOUR SERVER FROM CRASHING!

If someone came here with the problem of docker php official images, type below command inside the docker container.

$docker-php-ext-install mysql mysqli pdo pdo_mysql  For more information, please refer to the link above How to install more PHP extensions section(But it's a bit difficult for me...). Or this doc may help you. https://docs.docker.com/samples/library/php/ Fatal error: Call to undefined function mysql_connect() in C:\Drupal , In this Tutorial, I have explained how to fix the common Fatal error: call to undefined function Duration: 2:46 Posted: Sep 8, 2017 After starting the MySQL and Apache services through the service manager, you write a simple test php page to access the MySQL database. When the page is loaded in the web browser, you receive the error, Fatal error: Call to undefined function mysql_connect(). Sample Code. I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error. Then I came to this solution where I changed my code from depreciated php functions to new functions. $con=mysqli_connect($host,$user,$password); mysqli_select_db($con,dbname);
//To select the database

session_start(); //To start the session

$query=mysqli_query($con,your query);
//made query after establishing connection with database.


I hope this will help you . This solution is correctly working for me .

EDIT:

If you upgrade form old php you need to apt-get install php7.0-mysql

Fatal error:call to undefined function mysql_connect:Fixed, error Fatal error: Calling the undefined function mysql_connect () <?php $​enlace = mysql_connect('localhost', 'user_mysql', 'pass_mysql'); Problem: I am trying to use wp cli to do stuff. As an example update wordpress: wp core update Fatal error: Uncaught Error: Call to undefined function mysql_connect() in path\to\wp-includes\wp- SOLVED, PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C​:\inetpub\wwwroot\wp-includes\wp-db.php:1564. I've googled it and tried Fatal error: Call to undefined function mysql_connect() Kindly login to the cPanel >> Click on Select Php version >> select the extension MYSQL PHP Fatal error: Uncaught Error: Call to undefined function , Fatal error: Uncaught Error: Call to undefined function mysql_connect(). This appears to be as PHP7 no longer has anyway of connecting to a SQL database in it These are all files present in the latest wordpress update. One of them is requiering MySQL connect wich has been removed from php 7.2 and 7.3. Fatal error: Uncaught Error: Call to undefined function mysql_connect(), PHP + Windows – Call to undefined function mysql_connect(). author image. By mkyong | Last updated: November 16, 2017. Viewed: 25,746 | +19 pv/w. ##### Comments • How about other built in PHP/MySql functions? Do they work? • Perhaps not, as I have tried entering incorrect user/pass and my 'or die' statement is not showing! • Is this a better way to connect to a database? I will look into it but I would really like to get this working first as it worked previously until I moved to a new server. • It is. mysql_* functions are dangerous and deprecated as of PHP 4.1. Check your Apache error logs and restart the server. Does that work? • I'm using xampp, after adding that line to php.ini I get the following message in apache error.log Unable to load dynamic library '\\xampp\\php\\ext\\php_mysql.dll • @defmx Does the .dll file exist at that path? If not you need to install it. • I get Unable to locate package php7.0 • Replace 7.0 with 7.3 • Perfect solution for my case, I could not just upgrade yet and break all my existing code. However, the global$con variable in your file was a problem because the included file was not able to read the global variable of the parent class in which constructor I included it. However, I simply created a connection variable inside the functions of the included file where needed. Now my code works fine. Thank you.
• this was very helpful to me in getting an old codebase running again on a newer server platform. cheers!
• Thanks .. it saved my life where production was upgraded to php7 and php5 application broke down
• This is a great workaround to save time having to upgrade an ancient PHP application. Many thanks.
• thanks @ubo77. saved some headaches on a legacy codebase.
• mysql is what I want