Free2Code
 
Time: 2008-11-20, 10:30pm
Script Error
Subject: Script Error  ·  Posted: 2007-09-09, 12:40pm
Rank: ? (3)
Member #: 29659
Ok, I've used the Login Script, copied and pasted everything correcltly, but I get this error:
Fatal error: Undefined class name 'db' in /home/truedrea/public_html/my/db_connect.php on line 19
Fatal error: Undefined class name 'db' in /home/truedrea/public_html/my/db_connect.php on line 31

And this is my page in db_connect.php:
Code:
  1. <?php
  2. //require the PEAR::DB classes.
  3. require_once 'DB.php';
  4. $db_engine 'mysql';
  5. $db_user 'xxxxx';
  6. $db_pass 'xxxxx';
  7. $db_host 'localhost';
  8. $db_name 'xxxxx';
  9. $datasource $db_engine.'://'.
  10.               $db_user.':'.
  11.               $db_pass.'@'.
  12.                $db_host.'/'.
  13.                 $db_name;
  14. $db_object DB::connect($datasourceTRUE);
  15. /* assign database object in $db_object, 
  16. if the connection fails $db_object will contain
  17. the error message. */
  18. // If $db_object contains an error:
  19. // error and exit.
  20. if(DB::isError($db_object)) {
  21.     die($db_object->getMessage());
  22. }
  23. $db_object->setFetchMode(DB_FETCHMODE_ASSOC);
  24. // we write this later on, ignore for now.
  25. include('check_login.php');
  26. ?>


Can someone please help me?

» Post edited 2007-09-10, 07:28am by relpats_eht.

 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-10, 04:10am
Rank: ? (4821)
Member #: 3416
do you have PEAR installed? if not, i would expect it to fail at the require_once line at the top. then again if you have your own file named DB.php it would use that instead, and then you'd probably get this error.

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-10, 07:31am
Rank: ? (767)
Member #: 11085
As misterhaan has said, the reason for your error is likely that you do not have PEAR installed. This is not, however, your problem. This is your problem: "Ok, I've used the Login Script, copied and pasted everything correcltly but I get this error" That login script is part of a tutorial and not very well suited for use in a real application via copy and paste. It is useful for learning, but one doesn't learn by copy and pasting.

- relpats_eht
 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-11, 02:20am
Rank: ? (4821)
Member #: 3416
very good point, relpats_eth -- i hadn't fully read the original post and missed that part

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-13, 01:05pm
Rank: ? (3)
Member #: 29659
Yes, but isn't it also suppose to tell you what to do to make users sign up and login in the tutorial??? And how do I install PEAR?

 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-14, 11:52am
Rank: ? (767)
Member #: 11085
No, the purpose of the tutorial is simply to show the basic mechanics of a login script (and for the more aptly aware, that simple scripts are much more secure than complex ones).

As to installing PEAR, I am just going to point you to chapter 2 in the PEAR manual and also state (as I don't believe in posts being a solitary RTFM) that you will need to be developing on a local machine with PHP to be able to install. If you aren't working locally (that is, you upload everything to a website to run it), then you will have to ask your host to install PEAR. If you are not working locally and your host refuses to install PEAR, alert me to it and I will write up a second copy of that tutorial without the PEAR dependency (In fact, I may do that anyway, as this is quite a common problem.)

- relpats_eht
 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-15, 12:00pm
Rank: ? (3)
Member #: 29659
They said "NO"... I guess they have a lot of people on there servers and then they'd have to install it for everyone and prices will go up.... just a thought though... I'm not a host so yeah...

 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-16, 05:44am
Rank: ? (767)
Member #: 11085
Not really, they would only need to install it once (or once for each server, maybe) and PEAR is free.

Nonetheless, I'll get working on that PEAR-free port.

- relpats_eht
 
  Reply to this ·  Post link ·  Top
Subject: Re: Script Error  ·  Posted: 2007-09-19, 02:27am
Rank: ? (883)
Member #: 3
Same old song and dance...

» Post edited 2007-09-19, 02:27am by bs0d.

--bs0d | allsyntax.com
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons