PHP 5, Apache2, MYSQL 5, interoperability and config issues

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
amka
Forum Newbie
Posts: 5
Joined: Tue Nov 08, 2005 5:33 pm

PHP 5, Apache2, MYSQL 5, interoperability and config issues

Post by amka »

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hello,

I've tried to set small test platform up and I'm new to it:

WinXPPro
Apache 2.0.55
PHP 5.0.5
MySQL 5.0.15
MySQL Admin 1.1.4

All software is running on the same standalone box: HP Compaq

Apache 2 is configured and able to phpinfo on screen without any problems. 

Problem is in the second line of my short script. However, the PHP editor doesn't give me any parse errors. It looks like there is a problem connecting to my MySQL. My experiment indicates that if the MySQL server service is stopped there would be the same error  response on my script as soon as service up and running.

The error after i run this script:

Code: Select all

Fatal error: 

Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\index.php on line 2

Code: Select all

<?php 
$con = mysql_connect('127.0.0.1:3306', 'root', '1111'); 

if (!$con) {
            die("Unable to connect: " . mysql_error());
}
echo 'Connected OK!';
 
mysql_close($con); 

?>

I've done the following:


1. installed PHP to C:\php
2. coppied mysql dlls to C:\PHP diretory
3. renamed php.ini-default to php.ini and left in in C:\PHP directory
4. enabled c:\php path in XP system Variables
5. enabled mysql extensions in php.ini (php_mysql.dll, mysqli.dll)
6. left libmsql.dll in C:\PHP as advised by PHP doc!
7. enabled path include_path = ".;c:\php"


I can start and stop MySQL, create tables and manipulate them.

At the moment I can't move any further with this persistent error, as the mysql_connect cant connect! :(

I have searched through all possible links and sites for this error, checked my config against suggestions and I can't find any conflicts. Tried to reinstall MySQL, restart PC, Apache...nothing changes.


Guys pls assist me not to avoid this excellent experience in PHP programming! Apologise for a long message but this is all could help you to understand the situation.

Any advise is welcome!


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

What is the output of the following script?

Code: Select all

<?php
if (!extension_loaded('mysql')) echo "not loaded";
else echo "loaded";
?>
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Hi, this is a problem with PHP5.

You will need to copy two files into your C:\Windows\System32 directory (MUST be the System32 dir, will not work with them anywhere else!):

PHP\libmysql.dll

and

PHP\ext\php_mysql.dll

Then restart Apache.

HTH :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Actually, you don't need to copy those to %win%/System32 if you don't want to.

I have both %mysql%/bin and %php% in my PATH and it also works. For some reason i had to reboot first though. (Blame it on windows :p)
amka
Forum Newbie
Posts: 5
Joined: Tue Nov 08, 2005 5:33 pm

Post by amka »

hello timvw

I've reviewed my config and cleaned the registry off all PHP4, PHP 5.0.4 recordes. Reinstalled PHP 5.0.5 and start seeing MySQL section after phpinfo script run! that is a bit of achievement as it wasn't there before.

now i dont have that fatal error on my original script anymore. It appears I can connect to MySQL. your script showed "loaded" too!

My variable doesn't have path to Mysql\bin
I haven't put any files from PHP to either System32 or Windows

I can connect to server now and will try to play with my little db tables.

Thanks a lot for your speedy replies!
Post Reply