RE: [PEAR] getOne problem
| From: | Rich Payne | Date: | Mon, 24 Feb 2003 21:31:31 +0000 |
| Subject: | RE: [PEAR] getOne problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3930@lists.php.net to get a copy of this message | ||
Looks like $dbh in not a valid database handle then.
what does a var_dump($dbh) return?
--rdp
On Mon, 24 Feb 2003, Gigabyte wrote:
> the sql query i gave is actually just a dummy one. the query itself is
> correct (all the "'s in the right spot) -- and if i run the query from the
> mysql command line:
>
> mysql> SELECT id from login where name = 'bob';
> Empty set (0.00 sec)
>
> But when that same query is run from getOne (as all i want to return is the
> id) -- and if it exists, return ID, if not, return 0 :
>
> function getCookieID ($name=0) {
> GLOBAL $dbh;
> $sql = "SELECT id from login where name = '$name'";
> //error_log("getCookieID ".$sql);
> $res = $dbh->getOne($sql);
> if ($res > 0) {
> return $res;
> } else {
> return 0;
> }
> }
>
>
> Error Returned:
>
> [24-Feb-2003 13:01:03] PHP Fatal error: Call to a member function on a
> non-object in /xxx/login.class on line 15
>
> {line 15 is $res = $dbh->getOne($sql); }
>
>
>
> -----Original Message-----
> From: David DiMaria [mailto:ddimaria@eagledirect.com]
> Sent: Monday, February 24, 2003 1:21 PM
> To: 'Gigabyte'; Pear-General-Help
> Subject: RE: [PEAR] getOne problem
>
>
> I'm not sure if this is your problem, but your code:
>
> $dbh->getOne("select id from login where name="bob");
>
> may need to be changed to:
>
> $dbh->getOne("select id from login where name='bob'");
>
> -David DiMaria
>
> -----Original Message-----
> From: Gigabyte [mailto:gigabyte@superdudes.net]
> Sent: Monday, February 24, 2003 2:15 PM
> To: Pear-General-Help
> Subject: [PEAR] getOne problem
>
>
> I seem to be having issues with getOne.
> $dbh->getOne("select id from login where name="bob");
>
> If I send an sql query that returns an Empty Set, it comes back with the
> following error:
> Call to a member function on a non-object
>
> any suggestions?
>
> -Mike
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Rich Payne
http://talisman.mv.com
rdp at talisman dot mv dot com