note 45764 added to function.mysql-query

From: Date: Fri, 17 Sep 2004 15:56:58 +0000
Subject: note 45764 added to function.mysql-query
Groups: php.notes 
Request: Send a blank email to php-notes+get-76886@lists.php.net to get a copy of this message
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; ?> ---- Manual Page -- http://www.php.net/manual/en/function.mysql-query.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45764 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45764&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45764&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76886) next »