I've already installed apache server, php and mysql and they are working.
I can't configure php and mysql to work together. When I run the test, I receive the message: "Fatal error: Call to undefined function mysql_connect() in C:\apache\htdocs\mysql_test.php on line 9".
What can I do?

Dani AI

Generated

A few clarifying points that tie the suggestions from and together and explain what to check next.

When PHP reports that the MySQL connection function cannot be found, it usually means either the MySQL extension is not being loaded by PHP or Windows cannot locate the MySQL client library that the extension depends on. was correct to point at the extension configuration, and ’s final workaround shows the problem can also be a missing runtime DLL.

Quick troubleshooting checklist:

  • Use your PHP info output to see which configuration file PHP is actually using and what the extension directory is; that tells you which ini to edit and where PHP expects extensions to live (PHP configuration file docs).
  • If PHP under Apache is not picking up your ini, set the PHP configuration directory for Apache or place the ini where the Apache-loaded PHP build expects it; then restart Apache (Windows/Apache notes).
  • If the extension is enabled but functions are still undefined, Windows may be failing to load a dependency. Instead of only copying a DLL into the system folder, prefer adding the PHP installation (or MySQL client) folder to the system PATH or placing the matching DLL where Apache can load it. Verify builds match (32 vs 64 bit) and that the required Visual C++ runtime for your PHP build is installed. Check the Apache error log for extension load errors.

For long-term code, prefer mysqli or PDO_MySQL for newer PHP releases (mysqli docs).

Recommended Answers

All 3 Replies

Do you have the php_mysql.dll in the correct place and have you changed the line

;extension=php_mysql.dll

to

extension=php_mysql.dll

in your php.ini file?

I did, of course. They still don't work together. Another question is why, when I write localhost/info.php, in the seven's table row, it's written Loaded Configuration File -none.

At last I've solved this problem copying libmysql.dll in C:\windows\system32. (
It seems that php5 offer no support for mysql so we have to configure manually to work together).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.