Screen Data
Country USA (1)
State zzz
Abbreviation zz
State FIPS 123

Checking records for duplicate.....Found 0 duplicate entries
INSERT INTO tblState (CountryID, StateFIPS, StateAbbr, StateName, LockID, Status, Active) VALUES ('1', '123', 'zz', 'zzz', '0', '3', '1')
Result is
Record saved as: 0

dblink is defined as
$dblink = mysql_connect("$config_host","$config_user","$conf ig_password");

Code
DuplicateSQL ="SELECT * FROM `tblState` WHERE StateName=".sqlQuotes($StateName)." AND CountryID=".sqlQuotes($CountryID);
echo "<center>Checking records for duplicate.....";
$dblink = mysql_query($DuplicateSQL);
$num_rows = mysql_num_rows($dblink);
echo "Found ".$num_rows." duplicate entries<br>\n";
if ($num_rows == 0)
{ // Begin Save
$SaveSQL1= "INSERT INTO tblState (CountryID, StateFIPS, StateAbbr, StateName, LockID, Status, Active) VALUES ";
$SaveSQL2= "(".sqlQuotes($StateCountryID).", ".sqlQuotes($StateFIPS).", ".sqlQuotes($StateAb).", ";
$SaveSQL3= sqlQuotes($StateName).", ".sqlQuotes("0").", ".sqlQuotes("3").", ".sqlQuotes("1").")";
$SaveSQL= $SaveSQL1.$SaveSQL2.$SaveSQL3;
echo $SaveSQL."<br>\n";
mysql_query($SaveSQL);
$StateID=mysql_insert_id();
echo "Result is ",$result,"<br>\n";
echo "Record saved as: ".$StateID."<br>\n";
} else
{ // Duplicate entry
echo "Duplicate found. Please revise.....</center>\n";
}
FormOpen("State", "State", "post", "", "");