jjcanales Posted December 27, 2006 Share Posted December 27, 2006 I am still learning php and mysql. I am able to log into my mysql database and get the emails I need from the database, I can even get the correct ones to show that match the variables, but if the array returns with nothing, then I get a blank screen. I am trying to get it to tell me the array is blank and end the script when it is. I already know that when there are emails it will put them into my array. Any help appreciated. See what I have below. Thanks.Joe$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');mysql_select_db($dbname);$query = "SELECT email FROM users WHERE subscribepage = '$location_value' AND confirmed = 1 AND blacklisted = 0";$result = mysql_query($query);while (($row = mysql_fetch_array($result)) !== false){ $ADMIN_EMAILS[] = $row['email'];if (empty($email)){ echo "Sorry, we do not have anybody in your city at this time"; end;} mysql_close($conn); }} Link to comment https://forums.phpfreaks.com/topic/31937-php-and-mysql-array-problem-empty-array-help/ Share on other sites More sharing options...
Vikas Jayna Posted December 27, 2006 Share Posted December 27, 2006 The variable $email is not being assigned anywhere and hence the expression if (empty($email)) will always return true. Try changing this to if (empty($ADMIN_EMAILS)) Link to comment https://forums.phpfreaks.com/topic/31937-php-and-mysql-array-problem-empty-array-help/#findComment-148201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.