I am having a problem. I am trying to instert data into a database, but first check if it has already been entered (cause it was entering it twice. $tcom is equal to the number of records in a nother database, and makes arrays of some varibles.
for($i = 0; $i < $tcom; $i++) {
if($att[$i] == '') { $att[$i] = 'off'; }
$chk = "SELECT locatenum, com_nane FROM joint_meet WHERE locatenum = '$locnum' AND com_name = '$company[$i]'";
$chk_result = mysql_query($chk);
if(mysql_num_rows($chk_result) == 0) {
$sql = "INSERT INTO joint_meet (locatenum, attended, com_name, contact, phone, pgr, notes) VALUES ('$locnum', '$att[$i]', '$company[$i]', '$cn[$i]', '$ph[$i]', '$pgr[$i]', '$notes')";
$result = mysql_query($sql);
if(!$result) { echo mysql_error(); exit(); }
}
else {
echo "Record of Locate Number: <u>$locnum</u> and <u>$company[$i]</u> already exist in the database. Please go back and check if joint meet roster has already been filled.";
exit();
}
}
I added the if statement to get rid of the double entries, but now I get a mysql_num_rows error. It does however, instert the values in to the database..... anyone know why it would give me an error, or why it would give me doubles?
Thanks in advance,