Click to See Complete Forum and Search --> : [RESOLVED] PHP can't connect to MySQL 5.1


StevenJ
03-12-2009, 11:14 AM
I have just bought a number fo new components & Vista 64, & build a new PC. Following this, I am trying to get my PC in the state it was before for developing php/mysql

I have php 5 installed, and I belive this is working fine, although, it wasn't as straight forward as Win2K and php 4.0.

Now I have come to installing MySQL and I can't get PHP to connect. the output from phpinfo(); doesn't list anything to do with MySQL and my scripts can't connect, an example error being Fatal error: Call to undefined function mysql_pconnect() in C:\localhost\blahwebsite\Connections\photogallery.php on line 9

I have followed all the straightforward instructions and even looked for a tutorial to do this, but still I cannot get it to work.

If I go to the MySQL command line promt, that is working fine, so MySQL is ok.

Finally, i have uncommented the lines in the php.ini file so they should load the extensions.

extension=php_mysql.dll
extension=php_mysqli.dll

I always considered myself to be very pc litterate, now i am unsure, HELP!

is there anything that is fundamental in getting the two to connect?

I even tried going back to MySQL 4 - but that didn't work either................

NogDog
03-12-2009, 12:05 PM
Are the actual DLL files in your PHP/ext directory (or whatever directory is pointed to by your extension_dir setting in php.ini)? Does your Windows search path setting include that directory?

StevenJ
03-12-2009, 02:08 PM
they are, yes:

Loaded Configuration File C:\Windows\php.ini

both

php_mysql.dll
php_mysqli.dll

are in the ext directory,

checking the extension_dir in the php.ini file, I can see the following........

extension_dir ./ext

StevenJ
03-12-2009, 02:15 PM
duplicate post...sorry

NogDog
03-12-2009, 02:34 PM
What about the Windows path setting?

Start -> Settings -> Control Panel -> System -> Advanced System Settings

That should bring up the System Properties window. Select the Environment Variables button. In the System Variables section of that window, find and select the "Path" variable. Click Edit, and make sure it includes the path to your main PHP directory. (In my case it's C:\wamp\bin\php\php5.2.6, but yours might be as simple as C:\PHP). Be sure to use a semi-colon separator between it an the existing paths.

(Or if you get fed up with all of this, delete/uninstall everything and download and install WAMP or XAMPP. ;) )

NogDog
03-12-2009, 02:36 PM
PS: my php.ini file uses a full path to the ext dir, e.g. "C:/wamp/bin/PHP/ext".

StevenJ
03-12-2009, 03:18 PM
I checked the $PATH variable, and the C:\PHP was not there, so, I have included that now, and rebooted to ensure that this variable is collected.

I show a screen grab of this
http://www.webdeveloper.com/forum/attachment.php?attachmentid=12391&stc=1&d=1236888756

the output from phpinfo(); shows extension_dir c:\php\ext, as I have changed this to reflect the full path.

does the path need tp be c:\php\ext or will c:\php suffice?

NogDog
03-12-2009, 05:35 PM
My Windows path just points to the main PHP directory, while the php.ini extension_dir points to the /ext directory just under the main PHP directory.

Oh, another thing I've seen people say is that the mysql DLL files must only be in the PHP extension directory: there should not be copies of them under the Windows directory tree.

If that still doesn't get things running, take a look at this thread (http://phpbuilder.com/board/showthread.php?t=10340995) at PHPBuilder.com and see if there's anything else missing.

PS: I just noticed you have a thread open there, too. Hopefully one of those guys with more installer knowledge can get you straightened out.

StevenJ
03-12-2009, 06:40 PM
Thanks NogDog.

I went for the WANP installation. I usually don't like installing third party stuff - but this seems pretty good.

Anyone else having trouble with PHP5, MySQL 5.1 & IIS7 - I recommend you ditch the individual installs, and look at

http://www.wampserver.com/en/

regards

NogDog
03-12-2009, 08:11 PM
For a local test bed on a Windoze PC, I like WAMP. The run-time interface from the system tray icon is slick and really convenient when you want to make quick changes to your configuration.