RE: [PEAR] numRows() trouble....
| From: | Lukas Smith | Date: | Thu, 29 May 2003 16:30:12 +0000 |
| Subject: | RE: [PEAR] numRows() trouble.... | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5681@lists.php.net to get a copy of this message | ||
> From: a.bashir@tees.ac.uk [mailto:a.bashir@tees.ac.uk]
> Sent: Thursday, May 29, 2003 6:05 PM
>
> Being new to PHP and PEAR I may be missing something but I wanted to
> retrieve the number of rows from a query, in particular I wanted to
> check if only one row is being returned.
>
> I tried the following code:
>
> $sql = "SELECT * FROM users WHERE swipe_id = '$clientid'";
> $result = $db_obj->simpleQuery($sql);
> if (DB::isError($result)) {
> die($result->getMessage());
> }
> $result_num = $db_obj->query($sql);
> $num = $result_num->numRows();
>
> But I get:
>
> Fatal error: Call to a member function on a non-object in
> /usr/local/apache/htdocs/icon/prodigy/result_clientsearch.php on line
> 39
>
> line 39 : $result = $db_obj->simpleQuery($sql);
it just seems that $db_obj does not contain a PEAR DB object. Most
likely it contains an Error object.
Please do
print_r($db_obj);
or
if (DB::isError($db_obj)) {
die($db_obj->getMessage());
}
also please read up on PEAR error handling:
http://www.phpkitchen.com/staticpages/index.php?page=2003041204203962
http://php-mag.net/itr/online_artikel/psecom,id,330,nodeid,114.html
regards,
Lukas