2

I'm trying to get a local development environment setup on my windows machine using valet for windows. It works as intended for laravel and standard applications, but not for installing wordpress. It returns a fatal error.

I'm running php version 7.2.22, laravel valet for windows 2.1.1, mysql version 8.0 and wordpress version 5.2.3. I am trying to move away from a MAMP setup and therefore have gone through the process of setting up valet for windows.

I have checked that the credentials I have provided for the local database are correct, mysql is using port 3306, port 80 is free for valet to use.

After providing the details of my local database (which worked just fine in my MAMP setup) in my wp-config.php file, I try and go through the installation stage, and after I have entered all the correct credentials I receive the following error:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\Users\...

Now from my understanding and from prior researching, mysql_connect() has been deprecated since php5, however I thought wordpress provided a fallback for this in case people were using 7.2. I am using wordpress version 5.2.3.

Hayden
  • 241
  • 3
  • 6
  • Can you try and roll it with 7.1? – mediaguru Sep 26 '19 at 20:35
  • Running any plugins? Does `wp-config.php` have `define('WP_USE_EXT_MYSQL', true);` in it? – Jamesking56 Sep 27 '19 at 12:45
  • @Hayden did you resolve the issue? If yes how? I am having same issue with valet for windows and php7.3 with latest wordpress. Jamesking56 I do not have this line in my wp_config – Imran Mar 19 '20 at 16:07
  • @Imran In the end I did get this working but not through anything that I remember doing. I left it for a while, worked on other things then eventually came back to this to try and figure it out again, then it just started working as normal. I cannot say why or how, but it could be to do with the fact I had shutdown/restarted my computer in the meantime. I am now using a Mac, however going forward if I have to use Windows again, I will probably go down the route of installing WSL, so I can have a more Unix-like experience. – Hayden Jul 18 '20 at 10:26

1 Answers1

0

I believe that PHP 7.2 hasn't been installed properly. I'd probably check for the existence of the constant below in your wp-config.php file, and if that's non-existant, try re-installing PHP 7.2.

WordPress only uses mysql_connect when it thinks you're running PHP 5.x for backwards compatibility.

Please check your wp-config.php file for the following line:

define('WP_USE_EXT_MYSQL', true);

If you find it, delete the line. Your problem should be fixed.

If you still have the problem, then you incorrectly installed PHP 7.2.x. The error you reported is not possible if you are using PHP 7.2.x and the above line isn’t in wp-config.php.

Source: https://wordpress.org/support/topic/php-fatal-error-uncaught-error-call-to-undefined-function-mysql_connect-in/#post-10569776

NB: If you've installed PHP 7.2 but PHP isn't in your PATH, this may also cause this issue.

Mikey
  • 21
  • 5