tags:

views:

411

answers:

1

I currently have a website running MySQL and PHP in which this is all working. I've tried installing WAMPServer to be able to work on the site on my own computer, but I have been having issues trying to get the site to work correctly.

HTML and PHP files work correctly (by going to http://localhost/index.php, etc.). But some of the pages display "This Webpage is not available" (in Chrome) or "Internet Explorer cannot display this webpage", which leads me to think there is an error is the server, as when the page doesn't exist, it typically dispays "Oops! This link appears to be broken" or IE's standard 404 page.

Each page in my site has an include() call to set up an instance of a class to handle all database transactions. This class opens the connection to the database in its constructor. I have found commenting out the contents of the constructor will allow the page to load, although this understandably causes errors later in the page.

This is the contents of the included file:

class dbAccess  {
    private $db;

    function __construct() {
        $this->db = mysql_connect("localhost","root","") or die ("Connection for database not found.");

        mysql_select_db("dbName", $this->db) or die ("Database not selected");
    }
    ...
}

As a note for what's happening here. I'm attempting to use the database on my site, rather than the local machine. The actual values of dbName, user, and password work when I plug them into my database software (Navicat Lite) and work correctly on the finalized version of the site, so I don't think the issue is with those values themselves, but rather some setting with Apache or Wamp.

This is an excerpt of my Apache error log for one attempt at logging into the site:

[Wed Apr 14 15:32:54 2010] [notice] Parent: child process exited with status 255 -- Restarting.
[Wed Apr 14 15:32:54 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Wed Apr 14 15:32:54 2010] [notice] Server built: Dec 10 2008 00:10:06
[Wed Apr 14 15:32:54 2010] [notice] Parent: Created child process 1756
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Child process is running
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Acquired the start mutex.
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Starting 64 worker threads.
[Wed Apr 14 15:32:55 2010] [notice] Child 1756: Starting thread to listen on port 80.

I've tried searching for solutions online, but haven't been able to find anything to help. If you need any further information to help solve this issue, feel free to ask for it.

(One more note, I don't even have Skype on this computer, so I can't see it being an issue, as this conflict seems to be the default response for any Wamp issue.)

[Edit: Removed entry from the error log as it was solved as an unrelated issue] [Edit: Looking through my hosts documentation, I found that all ports besides 80 and 443 (for HTTP and HTTPS) are blocked, meaning they don't allow external connections like what I was trying to do here. I've changed it to the local database, but I'm still receiving the same error. The issue is still open.]

A: 

Let's by-pass the apache for a moment. In the directory <wamp>/bin/php/php5.3.0 there is a php.exe that implements the cli sapi (the command line version).

Put the file test.php in that directory with

<?php
if ( !extension_loaded('mysql') ) {
    die('the mysql extension is not present');
}

echo 'phpversion=', phpversion(), "\n"; flush();
echo 'client_info=', mysql_get_client_info(), "\n"; flush();

$mysql = mysql_connect('localhost', 'root', '') or die(mysql_error());
echo "seems to be working\n"; flush();

echo 'server_info=', mysql_get_server_info($mysql), "\n"; flush();

as the content. Then open a command shell, "go" to the directory

c:
cd c:\wamp\bin\php\php5.3.0

and run

php.exe -f test.php

It should print something like

phpversion=5.3.2
client_info=mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $
seems to be working
server_info=5.1.37

(though the versions will be different in your case)

VolkerK
The first two lines appeared with the output: `phpversion=5.3.0client_info=mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $`
VOIDHand
After a bit of time (around 20 seconds), the following warning statement repeated 5 times in varying formats (I'm looking into what a 2002 error is.):`Warning: mysql_connect(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\wamp\bin\php\php5.3.0\test.php on line 10
VOIDHand
Looks like the MySQL server isn't running.
VolkerK
What would cause MySQL server to fail when I can run Navicat or MySQL Query Browser and get into both of them just fine?
VOIDHand
Maybe they are using named pipes instead of tcp to connect to the server. Does the MySQL server appear in the output of `netstat -ab -p tcp`? (It should list all currently used tcp ports and the "associated" application. Might take a while.)
VolkerK