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: Win/Apache2/PHP5/mySQL5 function problem - HELP!
Author
csorrows



Joined: 14 Jul 2006
Posts: 3

PostPosted: Fri 14 Jul '06 20:20    Post subject: Win/Apache2/PHP5/mySQL5 function problem - HELP! Reply with quote

I've tried everything I've read here and Google'd and still no luck, so any help appreciated!

When I try to execute mysql_connect, I get the following error from PHP (both onscreen and in a log file I capture errors in):

PHP Fatal error: Call to undefined function mysql_connect() in C:\apache2\htdocs\phptest.php on line 3

Here's the details on my install:

I had installed mySQL 5.0.18-nt a few weeks ago, and it works fine.

Yesterday, I installed the Apache httpd-2.2.2-win32-x86-ssl.zip package, and the php5apache2.dll-php5.1.x.zip package from here on ApacheLounge.

Per the Readme First !! file included with Apache, I did NOT install the Visual C++ 2005 Redistributal Package because I'm already running .NET Framework 2. I also installed Apache as a service.

I then downloaded the latest PHP5 from the official site and unzipped it to c:\php5 and added c:\php5 to my system PATH. Then, per ApacheLounge's PHP5 readme, I copied php5apache2.dll to c:\php5, and httpd.exe.manifest to c:\apache2\bin. I did NOT install the Visual C++ Redistributable Package, since I thought it wasn't needed since I'm running .NET Framework 2. I did add the following to httpd.conf:

LoadModule php5_module "c:/php5/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php5"

I restarted Apache and confirmed that Apache and PHP are working fine. phpinfo() works fine.

Then, I configured php.ini so that the mysqli extension is loading. I also copied php_mysqli.dll to the c:\php5 directory (since that's where the extensions dir points to), and libmysql.dll to c:\windows\system32 folder.

Restarted Apache, and confirmed that in phpinfo(), the mysqli extension IS listed as being loaded.

So everything seems to be loaded and installed fine, BUT when I try to run mysql_connect, I still get undefined function error.

I've enable E_ALL error checking and startup error checking in PHP, but the only error I see onscreen and in error log is undefined function.

This is really confusing because the mysqli extension seems to be loading fine in PHP and the details are visible in phpinfo() data, but I cannot seem to get any mysql functions to work.

I haven't loaded the Visual C++ 2005 Redist. Package at all because the readme for Apache said it wasn't needed if you're running .NET Framework 2, which I am. But do I need it for PHP5 functionality with mySQL? I don't want to install anything extra I don't absolutely need.

Any ideas??? This is driving me crazy!

Thanks!
Back to top
Steffen
Moderator


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

PostPosted: Fri 14 Jul '06 20:56    Post subject: Reply with quote

Since your php is running fine there should no need to install Visual C++ 2005 Redist package.

All looks ok what you have done, special that the Mysql extension shows up in phpinfo().

Where did you copied libmysql.dll from ?

Maybe your script has a issue ?

Have also a look at: http://dev.mysql.com/downloads/connector/php/

Steffen
Back to top
csorrows



Joined: 14 Jul 2006
Posts: 3

PostPosted: Fri 14 Jul '06 21:03    Post subject: Reply with quote

I went back and changed something, and I think I got farther...

I didn't have the "mysql.dll" extension enabled in PHP.INI, only the "mysqli.dll" extension.

I went back and uncommented both and restarted Apache, and now I'm getting an "access denied for user root" error. But at least it looks like it's getting past the undefined function error.

So...should both the mysql AND the mysqli extensions be enabled when running with PHP 5 and mySQL 5? The documentation I read made it sound like if running version 5 of both, only the mysqli should be enabled.

Steffen - I got libmysql.dll from the PHP 5.1.4 distribution, and copied it to c:\windows\system32 directory.

So I'm assuming both mysql and mysqli extensions have to be loaded? If so, I'll leave those both loaded, I was just concerned about conflicts with the two different extensions loading.

Now I guess I need to resolve the access issue. I'm using the correct password for "root" user in the mysql_connect statement, and I'm connecting via 127.0.0.1 (instead of localhost), so it should work. But at least I'm getting farther than I was before.
Back to top
Steffen
Moderator


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

PostPosted: Fri 14 Jul '06 21:08    Post subject: Reply with quote

Better to use the libmysql.dll from you mysql/bin .


Steffen
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Sat 15 Jul '06 8:51    Post subject: Reply with quote

Quote:
I went back and uncommented both and restarted Apache, and now I'm getting an "access denied for user root" error. But at least it looks like it's getting past the undefined function error.


It is possible to use both extensions, I have tested this rigorously without any errors. However, I have seen in writing that it is recommended that you use the MySQLi extension with MySQL 5.x +. When I write my own PHP code, I always use the MySQLi extension. When I use 'pre-packaged' PHP that DOES NOT support MySQLi, I use both extensions in tandem. If you DO NOT plan to use one of these extensions, then go ahead and comment it out.

Please post your connect string. I use something similiar to the following:

Code:
$host = "localhost";
$database = "theDBname"; /* this is used later in other files */
$user = "root";
$pass = "yourPassword";
$local = mysqli_connect($host, $user, $pass) or die("Could Not CONNECT:  " . mysqli_error());


Also - Check your MySQL setup/configuration. MySQL Administrator is good for checking all of the various options.
..
.
Back to top
csorrows



Joined: 14 Jul 2006
Posts: 3

PostPosted: Sat 15 Jul '06 15:51    Post subject: Reply with quote

Thanks for all the replies - got it working Smile

Turns out the access problem was caused by somebody else doing some database testing on this machine who had changed the root password on me and I didn't know about it.

Everything's working fine now. Time to start learning PHP. Thanks!
Back to top


Reply to topic   Topic: Win/Apache2/PHP5/mySQL5 function problem - HELP! View previous topic :: View next topic
Post new topic   Forum Index -> Other Software