PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
fatal error

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication
View previous topic :: View next topic  
Author Message
charlesp



Joined: 08 Jan 2008
Posts: 3
Location: Reno, Nevada USA

PostPosted: Tue Jan 08, 2008 8:11 am    Post subject: fatal error Reply with quote

I am fairly new to php and have just been introduced to pear. I am working thru a book by Larry Ullman called PHP 5 Advanced. There is a script in the book that uses the Auth package. When I try to run the script I get this error:

Fatal error: Class 'DB' not found in C:\PHP5\PEAR\Auth\Container\DB.php on line 150

My code is this:



Code:

<?php
require_once('Auth.php');
 
 // function for showing a login form
 function show_login_form() {
 
    echo '<form method="post" action="login.php">
   <p>Username <input type="text" name="username" /></p>
   <p>Password <input type="password" name="password" /></p>
   <input type="submit" value="Login" />
   </form><br />
   ';
   
   } // end show login form function
   
   // connect to the database
   $options = array('dsn' => 'mysql://username:password@localhost/auth');
   
   // create the Auth object
   $auth = new Auth('DB', $options, 'show_login_form');
   
   // add a new user
   $auth -> addUser('me', 'mypass');
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Restricted Page</title>
</head>

<body>

<?php
// start the authorization
$auth->start();

// confirm authorization
if ($auth->checkAuth()) {

   echo '<p>You are logged in and can read this. How cool is that?</p>';
   
   } else {  // unauthorized
   
      echo '<p>You must be logged in to access this page.</p>';
      
   }
?>


</body>
</html>

End of code


I am using PHP 5.0.23 and MySQL 5.0.37 on Windows XP Pro sp 2

Does anyone know how to fix this? I am really interested in learning php and PEAR.

Thank you
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Tue Jan 08, 2008 11:19 am    Post subject: Reply with quote

Do you have the DB package installed? If not, "pear install DB".
Back to top
View user's profile Send private message
charlesp



Joined: 08 Jan 2008
Posts: 3
Location: Reno, Nevada USA

PostPosted: Tue Jan 08, 2008 8:22 pm    Post subject: Reply with quote

Thank you. That fixed the error.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software