Re: numRows() trouble....
| From: | a dot bashir at tees dot ac dot uk | Date: | Thu, 29 May 2003 16:05:08 +0000 |
| Subject: | Re: numRows() trouble.... | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5680@lists.php.net to get a copy of this message | ||
Hello,
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);
Having tried different ways of querying for numRows(), but all end up
giving me the same error.
I suspect that I may need to upgrade PEAR, but not sure. If so where
and how can I get a version that supports this functionality. Can
anybody help PLEASE!
Regards
Anwar
On Mon, 3 Feb 2003 16:35:27 -0500 (EST), dmorris@zoo.uvm.edu (Dave
Morris) wrote:
>
>Hey Cory,
>Not sure if this will do anything, but here goes. Try
>
>$result = $db_obj->query($query);
>
>instead. usually when I get that error it is because my mysql statement
>is faulty. however "SELECT * FROM users" seems pretty straightforward
>given that 'users' exists. Hope this helps.
>
>-dave
>
>
>On Mon, 3 Feb 2003, Cory Hicks wrote:
>
>> Hello again....
>>
>> Thanks to the list for the recent help! I am now moving onto other cool
>> PEAR features, but seem to be having problems with numRows(). I keep
>> getting this error:
>>
>> Fatal error: Call to a member function on a non-object
>>
>> Here is the code:
>>
>> $query="SELECT * FROM users";
>>
>> $result=$db_obj->simpleQuery($query);
>>
>> if (DB::isError($result))
>> die($result->getMessage());
>>
>> $num = $result->numRows();
>>
>> What I am missing?
>>
>> Thanks,
>>
>> Cory
>>
>>
>> --
>> Cory Hicks <chicks@tri-intl.com>
>> TRI-International
>>
>>
>> --
>> PEAR General Mailing List (http://pear.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>