# Gentoo: PHP not emerging with MySQL Support



## Regicide (Aug 8, 2003)

I have had a webserver up and running for some time now and I recently decided to add MySQL support to it for database management. PHP worked perfectly, but I realized after emerging MySQL that I had not specified in the USE flag MySQL, thus MySQL was not built into PHP. So, I decided to first unmerge PHP and then remerged PHP with MySQL in the USE flag. First, the configuration could not complete because there was some error about java not being present, which it is. So, I read that I should add '-java' to my USE flag. Anyway, after emerging PHP, MySQL support is still not present. I get the following error when I try a simple MySQL PHP document:


> Fatal error: Call to undefined function: mysql_connect() in /var/www/localhost/htdocs/mysql.php on line 4


So, I decided to check the php.ini file and everything seems ok. Even when I explicitly load the mysql library into the php.ini file that same error occurs. Also, in the output of the phpinfo();, I see the following flag in the configure command: '--without-mysql'. Finally, I tried to unmerge and remerge php again, but this time I copied the output of: 'USE="mysql -java" emerge -pv dev-php/php'


> Calculating dependencies ...done!
> [ebuild R ] dev-php/php-4.4.0-r4 +X +berkdb +crypt +curl -debug -doc (-fdftk) (-firebird) -flash -freetds -gd -gd-external +gdbm -gmp -hardenedphp -imap (-informix) +ipv6 -java +jpeg -kerberos -ldap -mcal -memlimit -mssql +mysql +ncurses +nls -oci8 -odbc +pam +png -postgres +readline -snmp +spell +ssl +tiff +truetype +xml2 -yaz


If anyone has any ideas on how to add MySQL integration into PHP, it would be greatly appreciated.


----------



## tsunam (Sep 14, 2003)

First things first, did you restart mysql after you recompiled it with php support?

Secondary, what's the mysql.php (assuming this is a basic open connection to the database)?


----------



## Regicide (Aug 8, 2003)

> First things first, did you restart mysql after you recompiled it with php support?


Yes, I restarted both Apache and MySQL anytime that I changed or re-emerged anything.


> Secondary, what's the mysql.php (assuming this is a basic open connection to the database)?


mysql.php looks like the following:


> <?
> $user="testuser";
> $password="";
> mysql_connect(localhost,$user,$password);
> ...


testuser is a valid user with the correct permissions and the database test is existant and working.


----------



## Regicide (Aug 8, 2003)

I found the problem. When I originally emerged apache, I did so with emerging mod_php. So, the problem wasn't with php, it was with mod_php. Once I re-emerged mod_php with mysql as a dependency, everything worked fine.


----------



## tsunam (Sep 14, 2003)

ah  glad you found it. I'm surprised you haven't moved over with the new style apache and dev-lang/php which doesn't need mod-php installed anymore


----------

