ways to check a value exists
Posted: Tue May 13, 2003 9:13 am
this should be straight forward but somehow I can not get it to work. The problem must be in the condition I am using ( have tried several ways now) to ask whether a value is being passed for the query. When it finds an result it works fine, just when there's not a value there it passes through the function as if there is. Any help appreciated thanks.
Scroll down to the orange text for the bit at question.
Scroll down to the orange text for the bit at question.
Code: Select all
<?php
$query = "SELECT * FROM ccMembers WHERE user_from='$postcodeTown' && installer_approved='approved' ORDER BY user_id ASC ";
$searchResults = mysql_query($query) or die('error making query');
$resultRowCount = mysql_num_rows($searchResults);
$resultRow = mysql_fetch_assoc($searchResults);
$installerAddress = $resultRow['user_email'];
$installerFirstName = $resultRow['firstName'];
$installerLastName = $resultRow['lastName'];
$installerCompanyName = $resultRow['company_name'];
$installerEmailBody = 'Hi, Please contact '.$order->customer['firstname'].' '.$order->customer['lastname'].' either call them at '.$order->customer['telephone'].' or email them at '.$order->customer['email_address'].' about the order<br><br>'.$email_order. '<br><br>Please email CCTV-City at sales@cctv-city.com as soon initial contact with the customer is made. ';
$installerTextSubject = 'CCTV-City.com order made in your area. ';
// THE FOLLOWING CONDITION IF WHAT DOES NOT WORK
// I HAVE TRIED SEVERAL WAYS OF RUNNING THIS CHECK
if(!isset($installerAddress)) {
$webMonitorTextSubject2 = 'An order has been made but there is no installer in that area ';
$webMonitorEmailBody2 = 'The following order has been made but there is no installer in the area requested.<br><br>'.$email_order. '';
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, $webMonitorTextSubject2, nl2br($webMonitorEmailBody2), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');
}
else {
tep_mail('', $installerAddress, $installerTextSubject, nl2br($installerEmailBody), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');
$webMonitorTextSubject = 'An order has been made and sent to installer ';
$webMonitorEmailBody = 'Installer '.$installerFirstName.' '.$installerLastName.' from the company '.$installerCompanyName.' who can be contacted at '.$installerAddress.' has been informed of the order.<br><br>'.$email_order. '';
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, $webMonitorTextSubject, nl2br($webMonitorEmailBody), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, '');
}
}
?>