verN Posted April 14, 2007 Share Posted April 14, 2007 i get the following error- Notice: Undefined variable: emails in d:\..\ on line 49 $ret_email= "SELECT emailAddress FROM mailinglists WHERE seminarID= '$id'"; $email_result= mysql_query($ret_email, $dbc) or die (mysql_error()); // retrieves the date from a particular seminar number. while ($row=mysql_fetch_array($email_result)) { $emails = $row['emailAddress']; } // where the mailinglist is created then an email can be send line: 49 if($emails !="") { //can view the template { else { echo '<h1>need to create mailing list</h1>'; } what i am trying to do is to be able to check if the user has created a mailing list if they haven't then a message appears saying that the user need to create one. This code works where there are email addresses created however where there are no email address created then the message does appear that the user needs to create a mailing list however it also comes with the following error Notice: Undefined variable: emails in d:\..\ on line 49 i know that the email addresses in the emails variable are empty but how do i resolve this error thanks Link to comment https://forums.phpfreaks.com/topic/47045-solved-undefined-variable-error/ Share on other sites More sharing options...
Guest prozente Posted April 14, 2007 Share Posted April 14, 2007 //if $emails isn't set or is empty, display message and exit if(!isset($emails) || empty($emails)) { echo '<h1>need to create mailing list</h1>'; exit; } Link to comment https://forums.phpfreaks.com/topic/47045-solved-undefined-variable-error/#findComment-229457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.