Forum Moderators: coopster

Message Too Old, No Replies

PHP 5 not accessing MySQL 4.1

         

TheSeoGuy

1:49 pm on May 2, 2005 (gmt 0)

10+ Year Member



I recently set up the newest versions of php and mysql on a Windows 2000 Server running IIS 5.1.

I got PHP 5 up and running.
I got MySQL 4.1 up and running.

However, I can't seem to get my scripts to access the MySQL database. When I call any type of MySQL function, I receive a php fatal error that the function does not exist.

I have read a lot about this and it appears that as of php 5, it does not support the new MySQL by default. And to have it do this, I need to uncomment the extension for the MySQL.dll in the php.ini file. I have done this, but still can't get anything to work.

Has anyone here come across this and is there anything else I can try?

Thanks so much!

Stormfx

5:06 pm on May 2, 2005 (gmt 0)

10+ Year Member



You have to copy the php_mysql.dll to the win/system32 directory. If that doesn't work, look at php.net in the docs as I seem to remember there maybe being another file. I could be wrong, though :)

dreamcatcher

5:12 pm on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you also need to copy the libmysql.dll file to the windows system32 folder too.

dc

TheSeoGuy

5:47 pm on May 2, 2005 (gmt 0)

10+ Year Member



Stormfx & dreamcatcher, thanks for the replys.

I have tried both of your suggestions with the same results.

I have copied the php_mysql.dll from the php/ext/ directory to the winnt/system32/ directory as well as the libmysql.dll from the php/ directory to the winnt/system32 and I still can't use any mysql functions in my scripts.

I have tried copying these files seperately and together.

jatar_k

7:44 pm on May 2, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try this thread and see if it helps
[webmasterworld.com...]

TheSeoGuy

8:21 pm on May 2, 2005 (gmt 0)

10+ Year Member



Jatar_k,

Thanks for the link! That looks very promising.

I noticed they said to uncomment both
extension=php_msql.dll
extension=php_mysql.dll

and I have only been uncommenting
extension=php_mysql.dll

I will give this a try. Thanks again for the great link!

dreamcatcher

7:29 am on May 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



btw, when you make your changes, make sure you restart your Apache server. You probably do, but just thought I would mention it.

TheSeoGuy

1:52 pm on May 3, 2005 (gmt 0)

10+ Year Member



dreamcatcher,

Thanks, but I'm running IIS. I have stopped and restarted the web service a number of times during the process of moving and editing different files. I have tried all the suggestions and went through the information jatar_k sent me to through the above link and I cannot seem to get PHP to recognize any MySQL functions.

In fact, when I run the phpinfo, there isn’t even a MySQL section. I have searched for multiple php.ini files and can only fine one on my machine. It is in the c:\php folder. phpinfo says it is in the C:\WINNT folder, but I know this is not correct. And here is something strange. I renamed my php.ini file to php-old.ini and php still ran fine. Should I restart my web service after changing the name? If not, then doesn’t that mean there has to be another php.ini file somewhere? If there is, I cannot find it anywhere.

I was able to install PHP 4.3.3 and MySQL 4.0 on my machine at work a few months ago and everything runs smoothly using IIS 5.1 under Windows XP Pro. I wanted to get the new stuff set up at home and everything is running well, except PHP will not recognize MySQL functions…

Stormfx

5:51 pm on May 3, 2005 (gmt 0)

10+ Year Member



Hey, did you look in C:\WINNT (or whatever your WIN path is)? Make sure you sort by type and refresh it. If phpinfo() is saying that that's the configuration file it's using, then it should be. It just doesn't make sense for it to be wrong.

That WOULD explain all the problems you're having. If you're uncommenting the mysql extension in an ini file that PHP isn't using... See? :P

jatar_k

9:15 pm on May 3, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



my personal opinion is that when strange things like this happen

I start from scratch

rip every file having anything to do with php/mysql out of the machine, delete them for all eternity and then start the process from square one. I find I miss a small step and it is often easier to start over than it is to try and fix it.

TheSeoGuy

9:00 pm on May 4, 2005 (gmt 0)

10+ Year Member



You know jatar_k, I was going to do that, but when I tried to remove the php folder I got a sharing violation... Apparently something being used by windows itself... so I just kept it. I would really like to figure out what is missing…

Something of interest: I did notice that my version here at work states that the Configuration File (php.ini) Path is C:\WINDOWS\php.ini. It lists the actual ini file while at home it is C:\WINNT. It does not list the ini file, just the directory.

I tried moving the ini file from my C:\PHP directory to my C:\WINNT, Stopped and Started my Web Service and php ran but again without any MySQL support. Do I need to completely reboot my machine any time I move or make changes to the php.ini file before they will take effect? I though just stopping and starting the web service would be enough.

Oh, I also added C:\PHP to my Path system variable, so I would think I wouldn't even need to move my php.ini file from C:\PHP to C:\WINNT, but at this point I'm ready to try any combination of things.

TheSeoGuy

9:15 pm on May 4, 2005 (gmt 0)

10+ Year Member



I just did an experiment here at work.

I have NO System Environment Path variable for PHP.
I have NO php.ini file anywhere but in the C:\WINDOWS directory.

I pulled up phpinfo() and it said my file was located at:
C:\WINDOWS\php.ini

I went to the windows directory and renamed this file to php.ini.old

I then stopped and restarted the webservice.

Looking at phpinfo() again revealed that php did still work, but now my location was saying:
C:\WINDOWS

No php.ini file was listed. So, how is it running? This would make since why MySQL would not be supported if I am editing a file that the system is not reading (as StormFX stated), but where would it be? Is there some type of default file that gets php running that is maybe named something else?

Thanks again for all the help. If anyone can shed more light, I would be grateful.

Stormfx

10:08 pm on May 4, 2005 (gmt 0)

10+ Year Member



I think (maybe wrong) that PHP DOES actually look in the directory it starts from if it cannot find a php.ini file. Either that or it loads with a default configuration, one that it was compiled with. But it's hard saying for sure. You can either delete everything related to PHP and reinstall it, or you can delete any PHP ini files that are anywhere but C:\PHP and then set the system env var to allow PHP. How you do that is to right-click my computer. On the Advanced tab, click the Enviroment Variables button. In the LOWER section, the one labeled System Variables, click on Path and then Edit. At the very end of the line of bottom (Variable Value) box, type --> ;C:\PHP (make sure that C:\PHP and the item before it are seperated with a ; ) Oh, and you will have to reboot the machine.

That will make PHP look for everything BUT the two mysql extensions IN the PHP directory. Just make sure to create a PHP.ini file in the PHP directory ;)

TheSeoGuy

1:47 pm on May 6, 2005 (gmt 0)

10+ Year Member



Stormfx,

Thanks for the information. I have had both C:\PHP and C:\MySQL\bin in the Path Environment Variable this entire time now.

With that in place, and my php.ini file in the C:\PHP directory, PHP and MySQL ran fine, but MySQL extensions were not being recognized and phpinfo was telling me the file was located in the C:\WINNT folder...

NOW... I tried something more...
I noticed that the php install instructions state the following:
"If you are running Apache 2, the simpler option is to use the PHPIniDir directive (read the installation on Apache 2 page), otherwise your best option is to set the PHPRC environment variable. This process is explained in the following FAQ entry. "

I noticed I had originally put in the PHPRC environment variable, but later removed it because I thought the C:\PHP in the Path variable would be enough...

Well, it sounds like the C:\PHP in the path directory is to locate the php5ts.dll file and the PHPRC variable is so php can locate the php.ini file. Regardless, I added it. After rebooting my system, now I get that "the page cannot be found" when I load up any php pages.

Any ideas? Sorry about the continual posts, but I would really like to get this resolved and am at my wits end.

Thanks again.

Stormfx

7:23 pm on May 6, 2005 (gmt 0)

10+ Year Member



Well, I know that modifying the env path variables doesn't take affect until after reboot. You didn't have to add the MySQL env path, but since you did, that allows (maybe requires) you to move the two files required for mysql to the directory specified in the env path variable, at least I THINK. I run IIS, but server software doesn't matter as far as PHP talking to MySQL. If you're running PHP and using the env path variable, you should be able to have your php.ini in c:\php and the two mysql files should be in c:\%win%\system32 for PHP to talk to mysql.

I don't use apache, as I've managed to tweak IIS to a lot of the functionality that apache boasts :). But I would change whatever you changed before you rebooted back to what it was before and see if that's the problem - as a first step.

At this point, I'd scrap all the installs, delete related files and start over :)

1. Install MySQL.
2. Unpack PHP, edit the PHP.ini and keep it in the PHP folder.
3. Copy the two required files (php_mysql[i] and the other file) to win/system32
4. Add the PHP to env path variable.
5. Add the app mapping.
6. Reboot.

Works for me :)

coopster

1:47 pm on May 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



From the Forum Library:

Troubleshooting Steps for PHP/Apache on windows [webmasterworld.com]. Although Apache is mentioned in the title here, it really applies to how your installation finds the php.ini configuration and has some troubleshooting steps for MySQL as well.

Another gotcha that a lot of folks run into shortly after getting the configuration correct is the known MySQL password issue [webmasterworld.com].

Just a couple of extra troubleshooting threads for ya ...

TheSeoGuy

4:32 pm on May 18, 2005 (gmt 0)

10+ Year Member



Update or lack there of as an update would indicate some form of progress…

I found out that if your phpinfo() is displaying only the C:\WINDOWS or C:\WINNT as your configuration file as opposed to C:\WINNT\php.ini it does in fact mean that the php.ini file is not being found. How php still runs is beyond me, but this does make since as to why I am not able to use MySQL functions.

The instructions on php.net said to just copy the php.ini file into the directory that is being shown as your configuration file location if no file can be found.

I have done this, and now receive an error that states “No Input file Specified.” This error comes up when I attempt to run any php file. I have found a few things to try to correct this problem, but none of them seem to work.

Again, if anyone has any more info, I would appreciate it. I have just about given up.

So, thanks again to EVERYONE who helped me with this. If I learn any more, I will be sure to post it as to hopefully save someone the frustration I have gone through in getting this to work.

drewread

2:50 pm on Jun 22, 2005 (gmt 0)



The last post was May 2005... It is now June... did you find a resolution?

:)