Main Tutorials

PHP + Windows – Call to undefined function mysql_connect()

Install WordPress and hits the following error message :


Fatal error: Uncaught Error: Call to undefined function mysql_connect() 
	in C:\nginx-1.12.1\www\wordpress\wp-includes\wp-db.php...

Tested

  1. PHP 7.1.10
  2. WordPress 4.8.3
  3. Nginx 1.12.1
  4. MySQL 5.7.17
  5. Windows 10

Solution

To install WordPress, PHP needs Mysql extension, to fix this, loads php_mysqli.dll in php.ini file.

php.ini


; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"

extension_dir = "ext"

;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it

extension=php_mysqli.dll

;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll

On Windows, default PHP dll extensions, including php_mysqli.dll are stored in the c:\\your-php-path\\ext folder, make sure the extension_dir path is pointing to the correct folder.

Restart PHP, done.

References

  1. PHP php_mysqli.dll
  2. PHP extension_dir

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Aditi Phadnis
4 years ago

Hi mkyong.com, Can you help me with this error. I am facing the error on one of the NGO websites loksadhana.org