Re: [PHP] Re: Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-29 Thread Matt Neimeyer
 $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return $Ret; }
 I'm assuming that you are calling my_fetch_array() in a loop of some
 sort and so at some point there are no more records in the result.

Oh... Um... Yeah... Well... headdesk

So... Checking the docs... Returns an array of strings that
corresponds to the fetched row, or FALSE if there are no more rows.

Is there a way to differentiate between a FALSE for no more rows and an error?

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-29 Thread Ford, Mike
 -Original Message-
 From: Matt Neimeyer [mailto:m...@neimeyer.org]
 Sent: 29 July 2009 16:47
 
  $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return
 $Ret; }
  I'm assuming that you are calling my_fetch_array() in a loop of
 some
  sort and so at some point there are no more records in the result.
 
 Oh... Um... Yeah... Well... headdesk
 
 So... Checking the docs... Returns an array of strings that
 corresponds to the fetched row, or FALSE if there are no more rows.
 
 Is there a way to differentiate between a FALSE for no more rows and
 an error?

I don't actually think that mysql_fetch_array can return an error -- read that 
description again, it's very clear that you get an array of fetched values or 
FALSE for no more data, no other options. If there's any error occurring, it 
will be in the preceding mysql_query().


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Broken IF behavior? (Changing the branch changes the evaluation)

2009-07-29 Thread Shawn McKenzie
Ford, Mike wrote:
 -Original Message-
 From: Matt Neimeyer [mailto:m...@neimeyer.org]
 Sent: 29 July 2009 16:47

 $Ret = mysql_fetch_array($result); if(!$Ret) { } else { return
 $Ret; }
 I'm assuming that you are calling my_fetch_array() in a loop of
 some
 sort and so at some point there are no more records in the result.
 Oh... Um... Yeah... Well... headdesk

 So... Checking the docs... Returns an array of strings that
 corresponds to the fetched row, or FALSE if there are no more rows.

 Is there a way to differentiate between a FALSE for no more rows and
 an error?
 
 I don't actually think that mysql_fetch_array can return an error -- read 
 that description again, it's very clear that you get an array of fetched 
 values or FALSE for no more data, no other options. If there's any error 
 occurring, it will be in the preceding mysql_query().
 

Probably the only error you can get is: supplied argument is not a valid
MySQL result resource, if $result is not valid.  So you could check that
in the code that does the actual query.

As for the function, I would just do this:

function my_fetch_array($result)
{
if(version_compare($GLOBALS['Version'], 2.0, =)) {
return mysql_fetch_array($result);
} else {
return odbtp_fetch_array($result);
}
}

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php