I'm attempting to query another table in the same database, and I have the code connecting to the table. However, it is still throwing my error in regards to the query. Below is the code, sanitized from some sensitive passwords/usernames. I am currently editing it in advanced wizard mode, and it is currently situated in the events before the DB Save, and after the Handle Arrays.
Could I get any help to figure out what is really going on here?
<?php
// Using $form->data[xxxxxx] to store data from the Form array
$name = $form->data[lastName] . ', ' . $form->data[firstName];
$county = $form->data[county];
$address1 = $form->data[streetAddress];
$address2 = $form->data[address2];
$city = $form->data[city];
$state = $form->data[state];
$zipcode = $form->data[zipcode];
$phone = $form->data[phoneNumber];
$email = $form->data[email];
$ssn = $form->data[ssn];
$changes = $form->data[changes];
$additional = $form->data[additionalInfo];
$hostname = '-----';
$user = '-----';
$password = '-----';
$database = '-----';
$link = mysqli_connect($hostname,$user,$password,$database) or die("Unable to select database");
$query = sprintf("SELECT * FROM tblEmail
WHERE county='%s',
mysqli_real_escape_string($county));
$result = mysqli_query($query,$link) or die(Query will not run.);
// Statement will add the emails from the array
while ($row = mysqli_fetch_array($result))
{
$emailGroup = $row['emailGroup'];
$emailSupervisor = $row['emailSupervisor'];
}
mysqli_close($link);
$to = '-----';
$subject = $form->data[lastName] . ', ' . $form->data[firstName];
$message = 'User information has been provided as follows:' . "\r\n" . "Name: " . $name . "\r\n";
$message .= 'County Selected: ' . $county . "\r\n";
$message .= 'Address: ' . $address1 . "\r\n";
$message .= $address2 ."\r\n";
$message .= 'City, State, Zip: ' . $city . ', ' . $state;
$message .= ' ' . $zipcode . "\r\n";
$message .= 'Phone Number: ' . $phone . "\r\n";
$message .= 'Email: ' . $email . "\r\n";
$message .= 'Social Security Number: ' . $ssn . "\r\n";
$message .= 'Changes: ' . $changes . "\r\n";
$message .= 'Additional Information: ' . $additional . "\r\n";
$message .= "\r\n" . $emailGroup . "\r\n" . $query . "\r\n";
$message .= $row . $result;
$headers = 'From: donotreply@-----.com' . "\r\n" .
'Reply-To: donotreply@-----.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Could I get any help to figure out what is really going on here?