yeh sorry I didn't include it, the following outputs the errors. Since errors are stored in an array..
<?php
// print the error messages
if(!empty($error)) {
echo '<p class="errorheader">Error!</p>
<p class="error">The following error(s) occurred:<br />';
// prints each error that occurred
foreach ($error as $msg) {
echo " - $msg<br />\n";
}
echo '</p><p class="error">Please try again.</p>';
}
?>
// there's no errors
if (empty($error)) {
// Make sure the email address is available and there isn't a duplicate.
for($i = 0; $i < sizeof($eAdd); $i++) {
$dup = "SELECT seminarID FROM mailinglists WHERE seminarID='$id' AND emailAddress='$eAdd[$i]'";
$dup_result = mysql_query ($dup,$dbc) or die (mysql_error());
// if there isn't a duplicate email address continue
if (mysql_num_rows($dup_result) == 0) {
// This is used to make data safe before sending a query to MySQL.
$id =mysql_real_escape_string($id);
$updatesMade = false;
// update the database.
$updateM_query = "UPDATE mailinglists SET emailAddress='$eAdd[$i]' WHERE seminarID='$id' AND emailAddress='$oldEmail[$i]'";
//echo '<b>'.$id.'</b><br>';
//echo ''.$eAdd[$i].'<br>';
$updateM_result=mysql_query($updateM_query,$dbc) or die (mysql_error());
//echo $updateM_query;
// email addresss is inserted
if (mysql_affected_rows() >= 1) {
$updatesMade = true;
}
// If updates have been made, print a message.
if($updatesMade = true) {
// Print a message.
$changes[]="The changes have been updated.";
}
} else { // The email address is not available.
$error[]= "The email address <font color='black'>$eAdd[$i]</font> has already been added to the database!";
}
}
} else {
$error = NULL;
}
}
?>
Problem 1 is when i include an invalid email address, no message gets ouputted.
Problem 2 is when i update one email address, it gets updated but the for the other email addresses the follwoing error appears
Error!
The following error(s) occurred:
- The email address gdgttt@hotmaill.com has already been added to the database!
Please try again.
I think this may be due to the array and the for loop it runs through and I have tried to make chnages to it but to no avail.
tnaks