 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
charlesp
Joined: 08 Jan 2008 Posts: 3 Location: Reno, Nevada USA
|
Posted: Tue Jan 08, 2008 8:11 am Post subject: fatal error |
|
|
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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1051
|
Posted: Tue Jan 08, 2008 11:19 am Post subject: |
|
|
| Do you have the DB package installed? If not, "pear install DB". |
|
| Back to top |
|
 |
charlesp
Joined: 08 Jan 2008 Posts: 3 Location: Reno, Nevada USA
|
Posted: Tue Jan 08, 2008 8:22 pm Post subject: |
|
|
| Thank you. That fixed the error. |
|
| Back to top |
|
 |
|
|
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
|
|