Fw: [PHP-DB] checking for results return from mysql

From: Date: Sun, 05 Aug 2001 19:19:49 +0000
Subject: Fw: [PHP-DB] checking for results return from mysql
Groups: php.db 
Request: Send a blank email to php-db+get-11081@lists.php.net to get a copy of this message
meant ot post this to the list .. . > i tried this. but it appears if($result) always returns true . . .(or maybe > i am crazy but mine seemsed to. of course unless there is error. > > but i did find a function who i am open to better suggestions because it > seems kine out of the way solution > > if(mysql_fetch_array($result)) > { > > $mysql_data_seek($result, 0); > > while . . . . . > > > ----- Original Message ----- > From: "olinux" <olnx@yahoo.com> > To: "Jon Yaggie" <dmsales@design-monster.com>; "php-db" > <php-db@lists.php.net> > Sent: Monday, August 06, 2001 12:19 AM > Subject: RE: [PHP-DB] checking for results return from mysql > > > > try this > > > > $result = mysql_query($sql_query); > > > > if ($result) { > > while ($row = mysql_fetch_array($result)) { > > $var_1 = $row['var_1']; > > $var_2 = $row['var_2']; > > } > > } > > > > > > olinux > > > > -----Original Message----- > > From: Jon Yaggie [mailto:dmsales@design-monster.com] > > Sent: Sunday, August 05, 2001 1:36 PM > > To: php-db@lists.php.net > > Subject: [PHP-DB] checking for results return from mysql > > > > > > i suppose this much have a simple solution i am missing. but here is the > > situation. > > > > i want to checkand see if my query returned any results. problem is if i > > check liek this - > > if($results = mysql_fetch_array($result)) > > > > it appears that a resource is returned regardless. so this is always > true. > > > > the real problem is that i need to find out if something is returned > without > > actually accessing the data. because this if statement appears to be > > calling the first row of result data so later when i use a while loop to > go > > through the data i am missing the first result returned. > > > > i have tried putting a few other mysql function in the conditional. maybe > i > > am on the wrong path . . would one of the cariable functions like isset() > > or soemthing check this? > > > > > > > > > > > > > > > > > > Thank You, > > > > Jon Yaggie > > www.design-monster.com > > > > And they were singing . . . > > > > '100 little bugs in the code > > 100 bugs in the code > > fix one bug, compile it again > > 101 little bugs in the code > > > > 101 little bugs in the code . . .' > > > > And it continued until they reached 0 > > > > > > > > > > _________________________________________________________ > > Do You Yahoo!? > > Get your free @yahoo.com address at http://mail.yahoo.com >

« previous php.db (#11081) next »