RE: [PHP] test for empty $result??

From: Date: Mon, 10 Sep 2001 17:52:22 +0000
Subject: RE: [PHP] test for empty $result??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66792@lists.php.net to get a copy of this message
cool! thanks Sam and Jeff, for your responses! best, a > -----Original Message----- > From: Sam Masiello [mailto:smasiello@synacor.com] > Sent: Monday, September 10, 2001 1:48 PM > To: andrew@salamander.net; php-general@lists.php.net > Subject: RE: [PHP] test for empty $result?? > > > > Then you can use: > > if (mysql_num_rows($result) == 0) { > stuff here > } > > This will check the number of rows returned from your query. If zero, > then do something....modify as you need. > > HTH > > Sam Masiello > Software Quality Assurance Engineer > Synacor > (716) 853-1362 X289 > smasiello@synacor.com > > > -----Original Message----- > From: Andrew [mailto:andrew@salamander.net] > Sent: Monday, September 10, 2001 1:45 PM > To: jeff@hyrum.net; php-general@lists.php.net > Subject: RE: [PHP] test for empty $result?? > > thansk, but $result here is a Resource ID, and will be present even if > the > result set associated with it is null. > > best, > a > > > > -----Original Message----- > > From: Jeff Lewis [mailto:jeff@hyrum.net] > > Sent: Monday, September 10, 2001 1:43 PM > > To: andrew@salamander.net; php-general@lists.php.net > > Subject: RE: [PHP] test for empty $result?? > > > > > > Just use: > > > > if (!$result){ > > code here > > } > > > > Jeff > > > > > -----Original Message----- > > > From: Andrew [mailto:andrew@salamander.net] > > > Sent: Monday, September 10, 2001 1:34 PM > > > To: php-general@lists.php.net > > > Subject: [PHP] test for empty $result?? > > > > > > > > > I know that this has been discussed before, but I cannot find > > the threads > > > so... > > > > > > I have a function that does a mysql_query and want to break if > > > the SQL query > > > didn't return any rows in $result. > > > > > > empty(), isset() will not work, for obvious reasons. > > > > > > Can anyone suggest an alternative? > > > > > > $sql="select row from table where field = \"1\""; > > > $link_id = mysql_connect($hostname, $username, $password); > > > mysql_select_db($database, $link_id); > > > $result = mysql_query ($sql, $link_id) or die; > > > > > > //this doesn't work...right? > > > if (empty($result)) break; > > > > > > best, > > > andrew > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > > > > > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#66792) next »