php fatal error call to undefined function mysql connect

Fatal error: Call to undefined function mysql_connect()

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?

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

17 Answers 17

You upgraded to PHP 7, and now mysql_connect is deprecated. Check yours with:

Change it to mysqli_connect as in:

If you’re upgrading legacy PHP, now you’re faced with the task of upgrading all your mysql_* functions with mysqli_* functions.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

If you get this error after upgrading to PHP 7.0, then you are using deprecated libraries.

mysql_connect — Open a connection to a MySQL Server
Warning
This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.

Open your terminal and run bellow command.

If you are running PHP you will also need to install the php module for mysql 5:

Verify that your installation of PHP has been compiled with mysql support. Create a test web page containing and load it in your browser. Search the page for MySQL. If you don’t see it, you need to recompile PHP with MySQL support, or reinstall a PHP package that has it built-in

Check if you forgot to enable the options below(loads the modules for mysql among others):

In PHP 7. You probably have PHP 7 in XAMPP. You now have two option: MySQLi and PDO.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

This error is coming only for your PHP version v7.0. you can avoid these using PHP v5.0 else

i made only mysqli from mysql

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

For CPanel users, if you see this error and you already have PHP 5.x selected for the site, there might be a CPanel update that disabled mysql and mysqli PHP extensions.

To check and enable the extensions:

I had this same problem on RHEL6. It turns out that the mysql.ini file in /etc/php.d only had a module name but needed a full path name. On my RHEL6 system the entry that works is:

After modifying the file, I restarted apache and everything worked.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

A solution could be to use adapter functions like these to start using mysqli instead of mysql over your entire application:

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

Am using windows 8 n this issue got resolved by changing the environment variables

follow these steps: Open my computer properties->advanced system settings->Environment variables. Under ‘system variables’, select ‘path’ and click on ‘edit’ In ‘variable value’, add ‘C:\php;’ OR the path where php installed.

click OK and apply the settings and restart the system. It should work.

Here is a quick fix:

All the pros will probably hate me for this answer. But I got the same error on a server: Fatal error: Uncaught Error: Call to undefined function mysql_connect() that was using PHP 7. Did not have time to rewrite all the mysql code so a quick, temporary fix if anyone needs it is in CPANEL to look for PHP Configuration and change the version for that account to something like PHP 5.4 instead of PHP 7. Then the code worked fine without the above error.

If you are using Windows10, PHP 7.2 and try to connect to mysql. If this error occurred

Uncaught Error: Call to undefined function mysqli() in

The do the following steps to get it correct.

Источник

Fatal error: Call to undefined function mysqli_connect()

For 2 days now I’m trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I’ve bulid an application on a site, and the application deals with the reviews. But, I’m trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I’m trying to go to the pages from the application, I receive this FATAL ERROR:

Fatal error: Call to undefined function mysqli_connect()

The code that I wrote to connect to the database is this (with hidden credentials):

Why do I get the error? It works on the old server, and the code I think it’s not the problem, because it works on localhost, and on the new server it doesn’t. Can anyone help me?

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

14 Answers 14

If you host the server yourself, in the php.ini file remove the semicolon in front of the extension extension=php_mysqli.dll

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

sudo apt install php-mysqli

It works perfectly and it is version independent

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

On Ubuntu I had to install php5 mysql extension:

Late to the conversation.

If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:

In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:

Mine was a bit different for php7 on centos7.

If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.

You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache’s httpd.conf

On Raspberry Pi I had to install php5 mysql extension.

After installing the client, the webserver should be restarted. In case you’re using apache, the following should work:

if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

Mysqli isn’t installed on the new server. Run phpinfo() to confirm.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can’t really explain as to why.

For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.

After struggling to figure out what was giving me «Error 500» white screen from this «PHP Fatal Error,» I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).

I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.

Источник

Undefined function mysql_connect()

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.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

14 Answers 14

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.

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:

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.

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

Well, this is your chance! It looks like PDO is ready; use that instead.

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

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

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

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

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.

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.

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

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

Also make sure you have all the following lines uncommented somewhere in your apache2.conf (or in your conf.d/php.ini) file, from

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

My guess is your PHP installation wasn’t compiled with MySQL support.

You can check for complete instructions at http://php.net/manual/en/mysql.installation.php. Although, I would rather go with the solution proposed by @wanovak.

Still, I think you need MySQL support in order to use PDO.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

sudo apt get install php-mysql

This command will install php-mysql depending on the php you have already installed, so no worries about the version.

Then comes the unix specific solution, in the php.ini file un-comment the line

Then finally restart the apache and mysql services, and you should now see the mysql section under Configrations heading in phpinfo page

Источник

Call to undefined function mysql_connect

I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

13 Answers 13

After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).

Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.

If you haven’t read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.

Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.

php fatal error call to undefined function mysql connect. Смотреть фото php fatal error call to undefined function mysql connect. Смотреть картинку php fatal error call to undefined function mysql connect. Картинка про php fatal error call to undefined function mysql connect. Фото php fatal error call to undefined function mysql connect

Background about my (similar) problem:

PROBLEM Surfaced: Immediately after this change, all my mysql_connect() calls failed. It threw an error

fatal error: call to undefined function mysql_connect.

My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file «httpd.conf» (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes. You can check if «php.ini» is read from the right directory. Just type in your browser «localhost/index.php». The code of index.php is the following:

There is the row (not far from the top) called «Loaded Configuration File». So, if there is nothing added, then the problem could be that your «php.ini» is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from

Pay the attention that the last slash disturbed everything!

Источник

PHP Fatal error : Call to undefined function mysql_connect()

I have recently installed PHP 7.0.8 (ZTS) on CentOS 7 with the following configuration:

I can’t go on my website because I have the following nginx log error when I try to go on my website:

[error] 20609#20609: *8 FastCGI sent in stderr: «PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /adodb/drivers/adodb-mysql.inc.php:461

This website is ok on an another server configured with Debian8, PHP7 (same configuration like here).

I have installed MySQL 5.7 and Nginx 1.10. How I can correct this error?

3 Answers 3

To correct the error, you’ve basically got two choices, either

1) modify the code to remove references to the mysql extension (and use mysqli or PDO instead), or

2) install an older version of PHP (before PHP7) which supports the mysql extension

If what you claim is true. that mysql_ functions are working under PHP7, then the most likely explanation for that is that someone installed a third party module/library that exports mysql_ functions.

I believe there was some work done to build such a library, to provide backwards compatiblity. The library would interact with the database using using the newer PHP mysqli_ functions, and provide (mostly) compatible mysql_ functions for legacy applications.

But that’s not part of PHP7. That would be a third party add on.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *