hi,
i've found a piece of code on the web and want to modify it to suit my needs.
generally, it inserts a few values into DB, but before that checks against existing data if there aren't any duplicates.
i want to change it in such way to verify if 2 values are not repeated: $subscriber_email and $ subscriber_name
ORIGINAL CODE
function RecordAdd($TableName, $Record) {
global $MYSQLRecordAddError;
$Result=mysql_query("INSERT INTO $TableName VALUES($Record)");
if (!$Result) $MYSQLRecordAddError=mysql_errno();
}
$Record ="'$subscriber_email',";
$Record.="'$subscriber_name',";
$Record.="'$startday',";
$Record.="'No',";
$Record.="'No',";
$Record.="'$ip'";
RecordAdd($TableName, $Record);
if ($MYSQLRecordAddError=="1062") {
$Message1="xx.";
$Message2="XX.<br>";
}
MY CHANGE //doesn't work that's why i post here
//----------
function RecordAdd($TableName, $Record) {
global $MYSQLRecordAddError;
$Result=mysql_query("SELECT * FROM $TableName", $ConnectID);
while($query_data=mysql_fetch_row($Result)) {
if ($query_data[0]==$Record[0]) $MYSQLRecordAddError='0';
if ($query_data[1]==$Record[1]) $MYSQLRecordAddError='1';
if ($query_data[0] <> $Record[0] and $query_data[1] <> $Record[1]) {
$Result=mysql_query("INSERT INTO $TableName VALUES($Record)");
}
}
}
$Record ="'$subscriber_email',";
$Record.="'$subscriber_name',";
$Record.="'$startday',";
$Record.="'No',";
$Record.="'No',";
$Record.="'$ip'";
RecordAdd($TableName, $Record);
if ($MYSQLRecordAddError=="0") {
$Message1="xxx.";
$Message2="xxx".<br>";
}
elseif ($MYSQLRecordAddError=="1") {
$Message1="yyy.";
$Message2="yyy.<br>";
}
else {
}
any help would be appreciated
witold