Entry
"Fatal error: Call to undefined function: mysql_connect() in c:\inetpub\wwwroot\...."
Where did MySQL go? I'm using PHP 5.
Aug 30th, 2004 12:12
Philip Olson, Chaudhry M-Shahzad,
Note: The information in this faqt is specific to PHP 5.
PHP 5 no longer enables MySQL by default (nor does it bundle the MySQL
Client libraries). Instead, you'll need to manually install this
extension, just like you do with most every other extension. Here's an
official FAQ on why:
http://php.net/manual/en/faq.databases.php#faq.databases.mysql.php5
Linux and friends:
------------------
Source:
When compiling, use the --with-mysql option. Because PHP 5 doesn't
bundle the MySQL client libraries, you'll need those on your system.
If PHP cannot find your MySQL source, link to your prefix, such as --
with-mysql=/usr or similar.
RPMS:
Unsure of the differences at the time of this writing but most likely
you'll need to install php, mysql, and php-mysql rpms.
Windows:
------------------
The compiled Windows binaries (what you download off php.net) no longer
have MySQL enabled by default. Instead, you need to take the following
steps during setup:
a) Enable php_mysql.dll in php.ini Be 100% certain you are editing
the proper php.ini*
b) Be sure to copy the libmySQL.dll from the dll/ folder to the
location install.txt asks you to move all dll's in dll/ to.
This is the step most miss. Essentially it needs to be available
to your systems PATH which ideally you'll edit your Windows system
PATH environment variable to include the PHP dir. Doing so would
however require a reboot of Windows but in the end is worth it as
it means all PHP files are in ONE directory so upgrades are easy.
c) Restart web server
d) Further problems? Read the manual.
* http://php.net/manual/en/install.windows.manual.php
* http://php.net/manual/en/faq.installation.php
Other notes:
-------------------
The above all refers the the ext/mysql extension in PHP 5, which works
with MySQL 3 and MySQL 4.0.x If you're interested in MySQL 4.1 and
above, you should use the ext/mysqli PHP extension instead. This topic
goes beyond the scope of this faqt.
References:
-------------------
http://www.php.net/mysql