note 45764 deleted from function.mysql-query by tomsommer

From: Date: Fri, 17 Sep 2004 17:22:25 +0000
Subject: note 45764 deleted from function.mysql-query by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76890@lists.php.net to get a copy of this message
Note Submitter: Jonathan ---- A note for newbies like myself: if mysql_query runs but returns no rows, it will return a newline, NOT null, or false, or an empty string. For example: <?php $Query = "SELECT id FROM table WHERE name = 'Christie'"; $Qry = mysql_query($Query); if ($Qry == false) { echo("Query \"$Query\" failed; " . mysql_error() . "\n"); return null; } if ($Qry == "\n" ) return null; // That entry does not exist $Res = mysql_fetch_row($Qry); $Res = $Res[0]; // The id we want mysql_free_result($Qry); return $Res; ?>

« previous php.notes (#76890) next »