Forum Moderators: coopster
I am running:
Windows Xp SP2
apache2
php5
mysql4.x
The are all running fine from what I can tell.
I have 1 problem, I cannot connect to the mysql server using php, it's giving me the error noted in the subject line. The error says the function is undefined but I assume it is in the .dll file that the php.ini file loads(php5apache2.dll for php to work on apache and php_mysql.dll loaded as an extension for php to talk to mysql). Everything loads fine, I don't get any errors when starting up apache, the phpinfo() page works perfectly, but it juts won't talk to mysql server...
Any thoughts?
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.
php.inifile?
See step 6 in message #2 in Installing PHP5 Unders Windows XP and Apache [webmasterworld.com].
I know what the [DIR] means, I am saying I don't know how to compile PHP on a windows machine.
coopster:
I have uncommented all the extensions I wish to use, and I am not getting any errors that apache/php can't find anything(meaning I have the .dlls in the correct spot). It just doesn't know what the mysql functions are....
Any help would be appreciated. The php installation works fine otherwise, I've used basic php functions for, time, date, info... etc. They all work great, it just doesn't know where the functions for mysql are.
*edited for spelling/grammer*
let's take a step back and have a look at what's going on here.
>> I am not getting any errors that apache/php can't find anything
actually that's not true, you are getting an error that there is an undefined function, which means php can't find something.
>> I've used basic php functions
so we know that php is where it needs to be
>> I have the .dlls in the correct spot
so we know, and hopefully have checked a bunch of times ;), that the dll's are in the right spot.
So, the way I see it everything seems to be in the right spot except there seems to still be confusion. So how could everything be in the right spot yet php can't find it? First think how does php/apache find things?
php.ini
>> I have uncommented all the extensions I wish to use
ok, but, something is still wrong
do you have only a single php.ini? (I have heard this problem many, many times on windows installs)
are you positive you are editing the one apache is using?
delete or rename the one you are editing and see if it still runs as is
I'm going to go back to the very beginning and clean everything up, and configure it all again using the walk through.... who cares if I figure out what's wrong, I just want the damn thing to work :P
I'll report back asap.
Why would phpinfo() be saying it's using the php.ini file in C:\Windows when there isn't one there? Is it because that is where I first put the file?
Note** I have restarted apache and the computer multiple times
phpinfo().
C:\WINDOWS\php.ini
php.inifrom
C:\WINDOWS\to
C:\Program Files\Apache Group\Apache2\
phpinfo()again.
C:\Program Files\Apache Group\Apache2\
Therefore, I would venture to guess that if phpinfo() is telling you it found the php.ini file in a certain path, then it found it in that path. If you are using MS Internet Explorer for the browser, clear the cache and try again. If phpinfo() tells you that it found the file there, I'm guessing it found the file there. Try what jatar_k mentioned earlier, try renaming the only php.ini file you have to something like php.bak and stop and restart apache, and call phpinfo() again. If it works, then it is indeed finding the php.ini file somewhere else and you'll have to track it down.
php.inias well and stopped and restarted Apache. There is absolutely no
php.inifile on my system anywhere. Apache will start without error, and phpinfo() WILL indeed run, but searching down through the directives, I find absolutely zero reference to MYSQL, therefore the extension is not loading. The Configuration File (php.ini) Path still shows
C:\WINDOWSthough and I don't know why -- I would have to research this, and maybe it's a bug or perhaps it's an internal thing. Either way, it is a bit deceptive.
<edit>
OK, time out. I just realized that it says
C:\WINDOWS, not
C:\WINDOWS\php.ini! Yes, the
C:\WINDOWSdirectory is the last path being searched and it didn't find any
php.inifile there, so this is a correct identification.
Either way, all I have to do is copy my
php.inifile with my extensions uncommented back into the
C:\WINDOWSdirectory, stop apache, start apache, and I'm back on track.
[edited by: coopster at 2:47 pm (utc) on Sep. 30, 2004]
php.iniduring startup is on the Configuration [php.net] page and the FAQ [php.net] link from there.
One other thing that is coming to mind as I read those pages though is that you should also make sure you don't have a
php-SAPI.inifile laying around somewhere.
put your php.ini file in your apache2 directory and restart apache, and tell me if that changes your config location to apache2 directory....(edit DOH, you already did this....)
on mine, it doesn't change the install directory, but the FAQ link you gave says it looks in apache2 directory first, then goes out to the windows directory....
Mine doesn't change(whether it actually looks in different spots I can't be certain.).
What should I try next?....
phpfreaks [phpfreaks.com]
it doesn't help the situation much, but at least I'm not alone.
It really only says that the person having the problem went the cgi instead of the module way.
maybe I should try that :( I really think the module way is what I want.
[edited by: coopster at 4:13 pm (utc) on Sep. 30, 2004]
[edit reason] fixed sidescroll [/edit]
What do you have in Apache (
httpd.conf) for your PHP configuration settings?
By the way, I found what I was looking for earlier...
PHP searches for php.ini in the following locations (in order):
- PHPIniDir directive (Apache 2 module only)
- HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath
- The PHPRC environment variable
- Directory of PHP (for CLI), or the web server's directory (for SAPI modules)
- Windows directory (C:\windows or C:\winnt)
Resource:
[php.net...]
What I did....
In one of the tutorials that I read it told me to edit the PHPIniDir = "C:\PHP"
I've changed this back to "./" and it's now reading the apache directory for php.ini and loading the settings in there
*cheer* *cheer*
Thanks for getting me on the right track.
I'm getting more errors now, but they are different, it's "seeing" the mysql functions now, now I have to configure mysql properly :)
The example in the PHP Apache 2.0.x on Microsoft Windows [php.net] installation instructions is probably where you came across that directive and it's example setting. But you didn't change it to reflect the correct path to your
php.inifile ;)
Glad you got it.
I personally, would like to see php bomb out and say "Hey stupid, there is no php.ini file for me to read, where you said it was!"
would make troubleshooting this sort of problem alot easier :P