logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: PHP 5.1.4 will notconnect to mysql 5.0.24 (on XP)
Author
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Sun 13 Aug '06 18:15    Post subject: PHP 5.1.4 will notconnect to mysql 5.0.24 (on XP) Reply with quote

I've installed and configured the following according to instructions in:
Apache and PHP - A Fast, Reliable, and Proven Setup

httpd-2.2.3-win32-x86-ssl - from link on this site
php5apache2.dll-php5.1.x - ditto (to dev.mysql)
mysql-essential-5.0.24-win32 (dev.mysql)
php-5.1.4-Win32 - php site

I have apache working with php - php pages work as expected. The problem is that PHP and MySQL still don't connect.
This can be tested at the command line with:

php file

where file content is:
<?php
echo 'php running';
$dbcnx = mysql_connect('localhost');
echo 'connection' + $dbcnx;
?>

Output is:
php running
Fatal error: call to undefined function mysql_connect() ...

This implies to me that the apache install is not the problem.

OK, saw the note on the new PHP_MySQL connector, so downloaded:

php_5.1.4_mysql_5.0.22-win32
php_5.1.4_mysqli_5.0.22-win32

I went and installed the mysql version and got php to attempt to connect, with the now expected authentication error. I then tried to use the "i" version. I added php_msql.lib to the php\ext directory and added an "i" to relevant php.ini lines, but am back to undefined function mysqli_connect().


? why does this version of PHP not have a line for the extension my_sqli? in either php.ini example?

I just reinstalled everything and cannot even get the non-"i" authenticate error. I've also tried putting the new libmysql.dll into windows and windows\system32 with no luck.

This should be a 30 min project, but I've spent days. It would be nice to just get to work.

Should i just revert to php 4.4.3?

Thanks
Dave
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sun 13 Aug '06 18:18    Post subject: Reply with quote

If you run phpinfo(); page is there the mysql extension loaded?
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Mon 14 Aug '06 4:28    Post subject: Reply with quote

No, phpinfo() does not show mysq loaded.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 14 Aug '06 9:24    Post subject: Reply with quote

So you have to enable it in php.ini

from
Code:

#extension=php_mysql.dll


to

Code:

extension=php_mysql.dll


and copy

libmysql.dll from mysql\bin folder to Apache\bin folder

than it should work. Don't forget to restart Apache Wink
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Mon 14 Aug '06 10:19    Post subject: Reply with quote

I had already uncomented the

extension=php_mysql.dll

line have also played with using

extension=php_mysqli.dll

Since I need the mysqli version to connect to the later mysql versions (as far as I can tell). Regardless, neither helps.

I also just copied the mysql\bin\libmySQL.dll into apache2\bin and restarted apache with no luck.

Shouldn't I be able to run php from the command line and test PHP <-> MySQL without getting involved with apache - I know that PHP <-> apache works fine?

I've also tried removing comments from several of the other PHP extensions and do not see them popping up in either
php -m (list loaded modules)
or
phpinfo()

Now what?

Dave
Back to top
Xing
Moderator


Joined: 26 Oct 2005
Posts: 49

PostPosted: Mon 14 Aug '06 11:51    Post subject: Reply with quote

What about your extension_dir ?
Must be pointing to your php/ext, for example:

extension_dir = "c:\php\ext"


X
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Mon 14 Aug '06 16:13    Post subject: Reply with quote

extension_dir = C:\php\php5\ext\ is set (this is copied from phpinfo())

I'll try to download your more recent php file - the Bhutan Hospital has a 128kb link and it was failing earlier...

Dave
Back to top
Steffen
Moderator


Joined: 15 Oct 2005
Posts: 3092
Location: Hilversum, NL, EU

PostPosted: Mon 14 Aug '06 16:21    Post subject: Reply with quote

C:\php\php5\ext\

Is the real to your extension dir ?
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Mon 14 Aug '06 17:48    Post subject: Reply with quote

Yup!
Back to top
Xing
Moderator


Joined: 26 Oct 2005
Posts: 49

PostPosted: Mon 14 Aug '06 18:14    Post subject: Reply with quote

I am puzzled, looks you have all done wright.

Look in you Apache logs for indications.

What says in phpinfo() the following lines:
Configuration File (php.ini) Path ?
extension_dir ?
Server Root ?

Where did you installed php ? When you extension dir is C:\php\php5\ext\ , that is not common, mostly c:\php\

Afterall it looks like you have somewhere a path issue.

Oh, what are the php lines in you added to your Apache httpd.conf ?

X
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Tue 15 Aug '06 11:24    Post subject: Reply with quote

OK, I've installed the latest php from this site (php-5.1.4-Win32). It has the same behvior in that I have apache delivering php content, but cannot link/load extensions.

Using c:\php\php5 simplifies this a bit - I renamed the old php5 directory php5.old, and unpacked this into a new c:\php\php5 folder. I had origionally uses c:\php, but at one point tried php4, hence the second level.

In order to get the new php running, I had to add _2 to the load mod line
httpd.conf: (php lines)

LoadModule php5_module "c:/php/php5/php5apache2_2.dll
...
<IfModule dir_module>
DirectoryIndex index.php index.shtml index.html
</IfModule>
...
AddType application/x-httpd-php .php
...
PHPIniDir "C:/php/php5/"[url]

Again - this is not the problem. Shouldn't I be able to run php at the cmd line and test mySQL connections (just like a cgi) without Apache running?

From php.ini (diff from php.ini.recommended)

log_errors = On
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
doc_root = C:\apache2\htdocs"
extension_dir = "C:\php\php5\ext\"
extension=php_mysqli.dll

XP env:
PHPRC c:\php\php5\php.ini
and path has: c:\php\php5 (and reboot)

One ?. The default php.ini shows
extension_dir = "./"
am I correct in adding the \ext\ in this path. Reverting back to "./" or ".\" dosn't change things.

In this install, I have not yet tried adding the file from mySql:
php_5.1.4_mysqli_5.0.22-win32
as I assume that this version is correct.

[/url]
Back to top
admin
Site Admin


Joined: 15 Oct 2005
Posts: 692

PostPosted: Tue 15 Aug '06 11:30    Post subject: Reply with quote

Looks like, you are mixing two php versions and have still somewehere leftovers.

You ask for issues when mixing versions.

Advised is to remove all php stuff, start again, and follow the guide exactly at www.apachelounge.com/viewtopic.php?t=570
Back to top
dlh



Joined: 10 Aug 2006
Posts: 7
Location: Bhutan

PostPosted: Wed 16 Aug '06 11:17    Post subject: Reply with quote

I figured it out! The problem was not multiple versions - I know that from your prospective it seems like a possibility...

One needs to remember that php can exist independentently of apache and that a php -m shows all loaded modules, so if your php.ini file has a module to load (and there are not dll's above it in the file that are required) one should see say mysqli in that list. Likewise one can do a

php -r "some php function"

and get an error if it's incorrect.

Finally I took another detailed look through php.ini and found an unmatched " - it had swallowed the rest of the file...

Thanks for your time.

I should be pretty straight forward for one to get this running using the latest httpd and php files from this site and mysql from mysql. No need to deal with mysql connector modules as those your php5 are correct.

Dave
Back to top
1109KL



Joined: 31 May 2006
Posts: 5

PostPosted: Thu 24 Aug '06 3:57    Post subject: Reply with quote

could you give an example of the php function?
i trie php -m mysql and get some error msg with 1%. that is because i use the wrong dll. but when i swtich back. there is no error - still... i get this
Code:
Fatal error: Call to undefined function mysql_connect() in
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 24 Aug '06 9:08    Post subject: Reply with quote

Try this
Code:

php -h

That will show you all commands

php -m will show com compiled in modules. MySQL is not compiled in! You have to load the extension. In php.ini enable it (see posts above)

Than create a test.php in htdocs folder
Code:

<?php
phpinfo();
?>

call it from the browser with http://127.0.0.1/test.php
Back to top
1109KL



Joined: 31 May 2006
Posts: 5

PostPosted: Thu 24 Aug '06 18:39    Post subject: Reply with quote

when i run php -m i saw mysql in between libxml and odbc. don't that mean mysql is currently running with php?
and when i run that test;
Code:
php running
Fatal error: Call to undefined function mysql_connect() in F:\net\test.php on line 3
Back to top


Reply to topic   Topic: PHP 5.1.4 will notconnect to mysql 5.0.24 (on XP) View previous topic :: View next topic
Post new topic   Forum Index -> Other Software