mysql_connect() causes page to not display (WAMP)

Posted by VOIDHand on Stack Overflow See other posts from Stack Overflow or by VOIDHand
Published on 2010-04-14T19:43:12Z Indexed on 2010/04/15 3:23 UTC
Read the original article Hit count: 345

Filed under:
|
|

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("externalURL","user","password") 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 externalURL, dbName, user, and password work when I plug them into my database software and the file fine of the site, so I don't think the issue is with those values themselves, but rather some setting with Apache or Wamp. The issue persists if I try a local database as well.

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.

For the first line, isLoggedIn (from the first line) is a method of the class above. Assuming that the connection works, this error should disappear.

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]

© Stack Overflow or respective owner

Related posts about wamp

Related posts about php