# [web] Installing PHP + MySQL on Apache

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all, I'm trying to install Apache on Windows 2000. I've got Apache 2.0.50 set up fine, and I've got MySQL 4.0.20 installed. But, I can't get PHP to cooperate with MySQL. I've got PHP 5.0.1 working, but I get "Fatal error: Call to undefined function mysql_connect() in D:\www\test.php on line 2". So, I'm assuming that means that PHP isn't working with MySQL. I've heard that they changed PHP so it doesn't automatically load the MySQL extension at some point, but what do I need to do to get it to load it? I had a look at my php.ini, and I tried adding "extension=mysql.dll", "extension=php_mysql.dll", "extension=libmysql.dll" and "extension=libmysqli.dll" (at different times), and restarting apache between tests, but I still get the "call to undefined function" error. So, does anyone know what the correct extension name is? Theres "libsql.dll" and "libsqli.dll" files in my php install dir. I'm using a prebuilt PHP version (the zip version). Cheers, Steve

##### Share on other sites

POST PICTURES OF WAFFLES PLZ!!!

##### Share on other sites
php_mysql.dll is correct according to the docs:
Quote:
 In PHP 5, MySQL is no longer enabled by default, nor is the MySQL library bundled with PHP. Read this FAQ for details on why. Because of this, Windows users will need to enable php_mysql.dll inside of php.ini and either copy libmysql.dll into the Windows system directory or make it available to the PATH. For compiling, simply use --with-mysql=[DIR] where [DIR] points to your MySQL installation directory.

So... find that dll and make sure windows can find it. And find the libmySQL.dll and put that somewhere windows can find it, too.

John B

##### Share on other sites
EDIT: My posting speed leaves to be desired...

##### Share on other sites
Hmm... Tried that - no luck. I've tried moving libmysql.dll into my apache /bin directory, C:\WINNT and C:\WINNT\System32. All without any luck :(

##### Share on other sites
Quote:
 Original post by Evil SteveHey all, I'm trying to install Apache on Windows 2000. I've got Apache 2.0.50 set up fine, and I've got MySQL 4.0.20 installed. But, I can't get PHP to cooperate with MySQL. I've got PHP 5.0.1 working, but I get "Fatal error: Call to undefined function mysql_connect() in D:\www\test.php on line 2". So, I'm assuming that means that PHP isn't working with MySQL. I've heard that they changed PHP so it doesn't automatically load the MySQL extension at some point, but what do I need to do to get it to load it?I had a look at my php.ini, and I tried adding "extension=mysql.dll", "extension=php_mysql.dll", "extension=libmysql.dll" and "extension=libmysqli.dll" (at different times), and restarting apache between tests, but I still get the "call to undefined function" error.So, does anyone know what the correct extension name is? Theres "libsql.dll" and "libsqli.dll" files in my php install dir.I'm using a prebuilt PHP version (the zip version).Cheers,Steve

Did you include the correct files for the php5 install? The php files that need to be included have changed in php5. Refer to the php installation manual that came with your download for specifics, because sorry, I don't remember the specifc files. perhaps php5ts.dll or something like that? php4apache2.dll?

Also, I think the issues have been resolved but there were problems with the latest Apache + PHP. You might want to take that into consideration too.

##### Share on other sites
Quote:
 Original post by Charles HwangDid you include the correct files for the php5 install? The php files that need to be included have changed in php5. Refer to the php installation manual that came with your download for specifics, because sorry, I don't remember the specifc files. perhaps php5ts.dll or something like that? php4apache2.dll?

Yep - its php5apache2.dll, and its an added module to Apache.

PHP itself works fine, but it won't use the MySQL functions...

##### Share on other sites
I just did this myself last weekend.

Easiest way to do it is to add the paths to your PHP installation, your MySQL installation, and your Apache2\bin to your PATH environment variable. Then restart Apache if it's already running. That should do the trick.

Alternatively, I think if you actually copy the libmysql.dll and libmysqli.dll files into Apache's bin directory, restart Apache, that will work.

To be honest, even though I've set it up, I haven't actually tried making a mysql call in a PHP page via Apache yet, so it could be that it's not working for me yet either.

I'll try it out later tonight at home; you'll probably have it going by then anyways though.

- dorix

edit: Gah, there was only one reply when I started writing this.

##### Share on other sites
Ah... Now I'm getting somwhere. Its not reading the php.ini file at all. I changed some settings and restarted apache, and phpinfo() didn't say they'd changed.

My php.ini is in C:\WINNT\, isn't that right?

##### Share on other sites
My php.ini is in C:\WINDOWS...

##### Share on other sites
Yay! Fixed it. It appears that the docs are wrong. It ignores C:\WINNT\php.ini. Putting the ini file in C:\php\php.ini works perfectly.

Thanks all

##### Share on other sites
No problems, glad I could help Steve

##### Share on other sites
For future reference, the manual explains the places that the system will look for the php.ini file. It can be in the apache install directory (usually apache/apache2 with the newer apache versions [i.e. one directory up from htdocs]), the system root, and one other place I recall.

##### Share on other sites
Yeah, it also said it could be in C:\WINNT - But that seems to be wrong...

Ok, new question, which is stupidly simple, so I won't create a new thread; How do I import a file into MySQL?
I exported all my databases using php-My-Admin, but it doesn't appear to have a way to import the data it exported (which is useful). I have a file (localhost.sql), with a load of statements like:
CREATE DATABASE comic;USE comic;CREATE TABLE characters (  name varchar(20) NOT NULL default '',  desc text NOT NULL,  PRIMARY KEY  (name)) TYPE=MyISAM;

I've had a look through the MySQL documentation, and the only way I can find to import data is a table at a time. And since I have around 100 tables in total, that'd just be silly. I remember that in Oracle there was a way to goto the console and type "@localhost.sql" or something like that, and it'd just execute all the statements in the file.

Is there a similar method for MySQL?

Cheers,
Steve

##### Share on other sites
i don't know the answer to your question .. but realize you are talking about TWO different things ...

and

Executing SQL scripts on the database

Pretty sure mysql supports both, the First one is either thorugh a Load or LoadFile method ... can't remember.

oh wait, found it:

8.3.2 Executing SQL Statements from a Text File

apparently the "source" keyword acts like it does for unix shells. and also the "mysql dbname < filename" syntax is used in many examples to load sample databases in tutorials.

##### Share on other sites
Ah ha! Thats much better - I just have to split it into databases now. Well, it worked for the first database fine.

Cheers,
Steve