Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 10-07-2004, 12:44 PM Help with php
Junior Talker

Posts: 2
Trades: 0
I am trying to figure out why this code doesn't work...

$res =& $d->query('SELECT * FROM s_news');
$res = $res->numRows();
while ( $row = $res->fetchRow( DB_FETCHMODE_ASSOC ))
{
$article_id = $row['id'];
}

When I try to load the entire php script it gives this error:

Fatal error: Call to a member function on a non-object in /home/virtual/site148/fst/home/scorpio/public_html/test.php on line 19

which is: while ( $row = $res->fetchRow( DB_FETCHMODE_ASSOC ))
lunaios is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-07-2004, 02:43 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
I assume your using PEAR::DB?

The problem is probably because the query returned an error (thus, a DB_Error object) instead of the DB_Result object that you were expecting.

Try adding some error handling to it:
PHP Code:
if (DB::isError($res))
    die(
$res->getMessage()); 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help with php
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09583 seconds with 12 queries