logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

RE: getOne problem: msg#00390

Subject: RE: getOne problem
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@xxxxxxxxxxxxxxx]
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@xxxxxxxxxxxxxx]
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




<Prev in Thread] Current Thread [Next in Thread>