Jump to content

PHP database script runs via command line, not via Apache


Recommended Posts

I'm posting this here, since I believe it to be a setup/configuration issue on my local machine with PHP or Apache. Not sure which.

 

I have a simple PHP script to test database connectivity:

 

<?php

$username = "username";

$password = "password";

$hostname = "localhost";

$dbh = mysql_connect($hostname, $username, $password)

or die("Unable to connect to MySQL");

print "Connected to MySQL";

 

mysql_close($dbh);

?>

 

This runs fine via the command line, however when it's run via my local Apache webserver I get a connection timeout. If I run other PHP scripts, e.g. phpinfo(), they work fine. It seems to be when I try and do MySQL stuff. I've checked php.ini and I believe I am loading the right extensions and I think httpd.conf is setup okay:

 

  • extension_dir = c:/php/ext (which is right on my machine)
  • extension=php_mysql.dll is uncommented

 

I am currently running Apache/2.0.61 (Win32) PHP/5.2.5 on Windows XP Pro. I have tried the latest build of Apache/PHP (2.2.6 and 5.2.5) but still no joy.

 

What initially caused my concern, before this basic testing, was trying to do an install of CMS Made Simple. One of the setup pages goes off and makes the database tables necessary, however, when it ran it actually caused Apache to crash. My first line of investigation was CMS Made Simple, but my testing now confirms this is a PHP/Apache problem.

 

From those crashes, the Windows error dialogue box said:

 

szAppName : Apache.exe    szAppVer : 2.0.61.200    szModName : php5ts.dll

szModVer : 5.2.5.5    offset : 0000ab4a

 

And Apache's log said:

 

[Tue Dec 04 16:57:56 2007] [notice] Parent: child process exited with status 3221225477 -- Restarting.

[Tue Dec 04 16:57:56 2007] [notice] Apache/2.0.61 (Win32) PHP/5.2.5 configured -- resuming normal operations

[Tue Dec 04 16:57:56 2007] [notice] Server built: Sep  5 2007 09:55:35

[Tue Dec 04 16:57:56 2007] [notice] Parent: Created child process 1384

[Tue Dec 04 16:57:57 2007] [notice] Child 1384: Child process is running

[Tue Dec 04 16:57:57 2007] [notice] Child 1384: Acquired the start mutex.

[Tue Dec 04 16:57:57 2007] [notice] Child 1384: Starting 250 worker threads.

 

I'm tearing my hair out here! Does anyone have any ideas?

 

Many thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.