PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
MDB2 : PB to get number of result in a select

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database
View previous topic :: View next topic  
Author Message
riccco



Joined: 18 Nov 2007
Posts: 3

PostPosted: Sun Nov 18, 2007 9:57 pm    Post subject: MDB2 : PB to get number of result in a select Reply with quote

Hello,

i have this code that don't work :

Code:
...

$res =& $mdb2->query('SELECT DISTINCT titre * FROM fetched');

$row = $res->fetchRow();
if(empty($row['titre'])){ echo "vide";}else{  echo "plein";}


$mdb2->disconnect();
...


and this is the server response :

Call to undefined method MDB2_Error::fetchRow()

Is there somebody that can help me figure out the problem ?

thanks by advance

riccco
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1053

PostPosted: Mon Nov 19, 2007 1:25 am    Post subject: Reply with quote

$res is an instance of PEAR_Error (which doesn't have a fetchRow() method). It's likely that you're not connected to a database or that your SQL query is wrong.

For debugging (but not for production use, of course):

Code:

...
$res =& $mdb2->query('SELECT DISTINCT titre * FROM fetched');
if (MDB2::isError($res)) {
    die($res->getMessage . ', ' . $res->getDebugInfo());
}
$row = $res->fetchRow();
...
Back to top
View user's profile Send private message
riccco



Joined: 18 Nov 2007
Posts: 3

PostPosted: Mon Nov 19, 2007 11:46 am    Post subject: Reply with quote

@Mark:

Thank you very much. I see now that there was an error in my query.

ricco
Back to top
View user's profile Send private message
cfletcher1856



Joined: 23 Nov 2007
Posts: 7

PostPosted: Sat Nov 24, 2007 6:16 pm    Post subject: Reply with quote

riccco wrote:
@Mark:

Thank you very much. I see now that there was an error in my query.

ricco


Were you missing a , after DISTICT titre, *
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software