View Full Version : MySQL query. Error or not?
Cheap Bastard
June 16th, 2001, 11:31
just one question...
if i have this code of PHP
$result = @mysql_query(whatever,$dbconn);
will $result be empty when there is an error, or will $result be empty when there isn't an error...
lucifer
June 16th, 2001, 12:01
$result will be false ie 0 if there is an error
Cheap Bastard
June 16th, 2001, 17:52
just one more...
if you have
$result = @mysql_query(whatever,$dbconn) or die(whatever);
can result ever be empty/false/0 ?
lucifer
June 16th, 2001, 17:55
the result could be empty as in no records found
but if there's an error then die will kill the script so you never see $result again
Cheap Bastard
June 16th, 2001, 18:02
so you're saying if nothing's found it won't switch to die (and kill the script), it'll just give you a $result = 0/empty/whatever
lucifer
June 16th, 2001, 18:09
yep,
it'll die if there's an error
eg. MySQL is down
you aren't connected to it
your SQL is f****d
if all is well the $result id is the result
well it's more of a pointer to the result
anyhow you can then do things like
mysql_fetch_array($result)
get a row of info from the result
mysql_num_rows($result)
get number of rows in the result
so you never do
if ($result==...){...} cos it don't work like that
Cheap Bastard
June 16th, 2001, 18:27
do you want to be in the credits when this thing's done?
i mean, you almost wrote half the thing...
lucifer
June 16th, 2001, 18:33
PHP Manual :D
XL. MySQL functions
www.php.net
it's a pretty dull read but it's got half the answers :(
MySQL Reference Manual :D
www.mysql.com/documentation
has the other half and is an even duller read :(
happy reading :)
Cheap Bastard
June 16th, 2001, 19:38
... :D i'll take that as a no :rolleyes:
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.