SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Login Script Crashes Apache

    Windows XP Pro v2002 SP2
    Apache 2.2.4
    MySQL 5.0.37-community-nt
    MySQL Client 5.1.11
    PHP 5.2.1

    Before you tell me to google the solution to this, I already did. The problem is widespread and pervasive in the WAMP community and seems to have many different causes, each of which requires a different solution. I have tried a number of solutions, such as disabling Win32 AcceptEx, MMAP, & Sendfile, and installing different versions of PHP and the php_pdo_mysql.dll driver. Nothing seems to work. Further, the PHP developers generally seem too quick to dismiss this bug as bogus or unreproduceable in the numerous bug reports I've viewed.

    The problem:

    My login script has recently started crashing and restarting Apache. The error log says (you've probably seen this before - everyone else apparently has):

    [Fri Apr 27 12:16:43 2007] [notice] Parent: child process exited with status 3221225477 -- Restarting.
    [Fri Apr 27 12:16:44 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.1 configured -- resuming normal operations
    [Fri Apr 27 12:16:44 2007] [notice] Server built: Jan 9 2007 23:17:20
    [Fri Apr 27 12:16:44 2007] [notice] Parent: Created child process 2384
    [Fri Apr 27 12:16:44 2007] [notice] Child 2384: Child process is running
    [Fri Apr 27 12:16:44 2007] [notice] Child 2384: Acquired the start mutex.
    [Fri Apr 27 12:16:44 2007] [notice] Child 2384: Starting 250 worker threads.
    [Fri Apr 27 12:16:44 2007] [notice] Child 2384: Starting thread to listen on port 80.

    The Windows popup error message yields the following:

    szAppName: httpd.exe
    szAppVer: 2.2.4.0
    szModName: php_pdo_mysql.dll
    szModVer: 5.2.1.1
    offset : 000024ba

    and generously offers to schlep these files off to Microsoft:

    C:\DOCUME~1\CECILP~1\LOCALS~1\Temp\WER2a69.dir00\httpd.exe.mdmp
    C:\DOCUME~1\CECILP~1\LOCALS~1\Temp\WER2a69.dir00\appcompat.txt

    Here's the relevant portion of the script. The login function excerpted here is a class method. The other database-intensive methods of said class work fine, so I'll not cloud the issue by presenting the full class declaration. $Database is declared in my main script as follows:

    PHP Code:
    try {
     
    $Database = new PDO('mysql:host=localhost;dbname=database','username','password',array(PDO::ATTR_PERSISTENT => true));
     
    $Database->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
    }
     catch(
    PDOException $e) {
     die(
    $e->getMessage());

    The login function, to which $Database is passed as a reference:

    PHP Code:
    public function login($username,$password,&$db) {
        try {
         
    $query $db->prepare("SELECT count(*) FROM member WHERE username=?");
      
    $query->bindParam(1,$username);
      
    $query->execute();
      
    $result $query->fetch(PDO::FETCH_ASSOC);
      
    $count $result['count(*)'];
     }
     catch (
    PDOException $e) {
      
    $this->error "Error: Session::login failed. " $e->getMessage();
      return 
    false;
     }
     if (
    $count == 0) {
      
    $this->error "Error: Unknown nickname.";
      return 
    false;
     }
        try {
      
    $query $db->prepare("SELECT id,password,is_active,is_admin,is_mod,joined,last_login FROM member WHERE username=? LIMIT 1");
      
    $query->bindParam(1,$username);
      
    $query->execute();
      
    $result      $query->fetch(PDO::FETCH_ASSOC);
      
    $user_id     $result['id'];
      
    $is_admin    = ($result['is_admin'] == "Y");
      
    $is_mod      = ($result['is_mod'] == "Y");
      
    $joined      $result['joined'];
      
    $last_login  $result['last_login'];
      
    $login_time  mktime();
      
    $stored_pwd  $result['password'];
      
    $acct_active = ($result['is_active'] == 'Y');
     }
     catch (
    PDOException $e) {
      
    $this->error "Error: Session::login failed. " $e->getMessage();
      return 
    false;
     }
     if (
    $password != $stored_pwd) {
      
    $this->error "Error: Incorrect password.";
      return 
    false;
     }
     if (!
    $acct_active) {
      
    $this->error "Error: Inactive account.";
      return 
    false;
     }
     try {
      
    $query $db->prepare("UPDATE member SET last_login=? WHERE id=?");
      
    $query->bindParam(1,$login_time);
      
    $query->bindParam(2,$user_id);
      
    $query->execute();
     }
     catch (
    PDOException $e) {
      
    $this->error "Error: Session::login failed. " $e->getMessage();
      return 
    false;
     }
     if ((
    $aff_rows $query->rowCount()) === 0) {
      
    $this->error "Error: No rows affected updating member in Session::login.";
      return 
    false;
     }
     
    $this->set('logged_in',true);
     
    $this->set('user_id',$user_id);
     
    $this->set('username',$username);
     
    $this->set('login_time',$login_time);
     
    $this->set('is_admin',$is_admin);
     
    $this->set('is_mod',$is_mod);
     
    $this->set('last_login',$last_login);
     
    $this->error false;
     return 
    true;
    // end function login 
    The member table structure:

    CREATE TABLE `member` (
    `id` int(11) unsigned NOT NULL auto_increment,
    `username` varchar(24) NOT NULL,
    `password` varchar(32) NOT NULL,
    `email` varchar(255) NOT NULL,
    `is_active` enum('Y','N') NOT NULL default 'N',
    `is_admin` enum('Y','N') NOT NULL default 'N',
    `is_mod` enum('Y','N') NOT NULL default 'N',
    `joined` int(11) unsigned NOT NULL,
    `last_login` int(11) unsigned NOT NULL default '0',
    PRIMARY KEY (`id`),
    UNIQUE KEY `USERNAME` (`username`),
    UNIQUE KEY `email` (`email`)
    ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

    I have been seeking a solution for two days and am almost ready to abandon PDO and rewrite the whole application using the old MySQL extension. Any help would be greatly appreciated.

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, I just put the same scripts on another WAMP box with nearly the same software versions, config. files, etc., and it works fine.

  3. #3
    SitePoint Addict Trent Reimer's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by World Wide Weird View Post
    By the way, I just put the same scripts on another WAMP box with nearly the same software versions, config. files, etc., and it works fine.
    Glad to hear it. Now if I can be a jerk, here's another solution.

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by World Wide Weird View Post
    By the way, I just put the same scripts on another WAMP box with nearly the same software versions, config. files, etc., and it works fine.


    find you find out what the actual problem was? software configuration? or what? it would be interesting to have the the solution to the problem so it might get indexed by google and someone else with the same problem might find it someday

  5. #5
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Trent Reimer View Post
    Glad to hear it. Now if I can be a jerk, here's another solution.
    As a matter of fact, we're migrating our production server to Ubuntu soon. That doesn't explain the weird problem with Windows though.

  6. #6
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by voodoomagic View Post
    find you find out what the actual problem was? software configuration? or what? it would be interesting to have the the solution to the problem so it might get indexed by google and someone else with the same problem might find it someday
    No, I haven't had time to sit down and compare the httpd.conf, php.ini, and other files line-for-line yet. If you search for this particular issue (the bold text in my original post) on Google, you get hundreds of different answers. It appears that several modules besides php_pdo_x.dll cause the same problem under several different versions and combinations of Apache and PHP under Windows.

    EDIT: That said, I removed all the virtual hosting stuff in httpd.conf on the development server, since I'm only running one site on it at a time. I can't imagine that having anything to do with it, but you never know.
    Last edited by World Wide Weird; Apr 29, 2007 at 13:07. Reason: Added afterthought


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •