Page 1 of 1

error in try block

Posted: Tue Dec 27, 2005 1:34 am
by rajan

Code: Select all

<?php
/* Program: Auth-OO.php
   Desc:    Program that prompts for a user name and password
            from the user using HTTP authentication. The
            program then tests whether the user name and
            password match a user name and password pair
            stored in a MySQL database.
 */

 require_once("PasswordPrompter.class");              #@@a10
 require_once("Database.class");
 require_once("Account.class");
 require_once("WebPage.class");

 //Testing whether the user has been prompted for a user name
 if(!isset($_SERVER['PHP_AUTH_USER']))                #@@a16
 {
    try
    {
       $prompter = new PasswordPrompter("secret section");
       $prompter->displayPrompt();
    }
    catch(Exception $e)
    {
      echo $e->getMessage();
       exit();
    }
 }

 // Testing the user name and password entered by the user
 else                                                 #@@a31
 {
    try                                               #@@a33
    {
       $db = new Database("Vars.inc");                #@@a35
       $db->useDatabase("UserAccount");               #@@a36
    }
    catch(Exception $e)
    {
       echo $e->getMessage();
       exit();
    }                                                 #@@a42
    try                                               #@@a43
    {
       $acct = new 
          Account($db->getConnection(),"Valid_User"); #@@a46
       if(!$acct->selectAccount($_SERVER['PHP_AUTH_USER']))
       {
          $mess = $acct->getMessage();
          echo $mess."<br>";
          exit();
       }                                              #@@a52
       if(!$acct->comparePassword($_SERVER['PHP_AUTH_PW']) )
       {
          $mess = $acct->getMessage();
          echo $mess."<br>";
          exit();
       }                                              #@@a58
    }
    catch(Exception $e)
    {
       echo $e->getMessage();
       exit();
    }
  }                                                   #@@a65
  $data['user_name'] = $_SERVER['PHP_AUTH_USER'];     #@@a66
  try                                                 #@@a67
  {
    $welcome_page = new WebPage("Welcome.inc",$data); #@@a69
    $welcome_page->displayPage();                     #@@a70
  }
  catch(Exception $e)
  {
    echo $e->getMessage();
    exit();
  }
?>
there is error in try block what's the problem i am using php 4.2.3

Posted: Tue Dec 27, 2005 1:37 am
by d3ad1ysp0rk
Try and Catch wasn't put into PHP until version 5.