The second query works fine by itself, so why doesn't it work when the first query is in front of it and the else is triggered?
still spits out the print with no errors.
[PHP]
<? include("dbconn ect.php");
$result = mysql_query("SE LECT CTRL_NUM "
. "FROM inventory "
."WHERE CTRL_NUM = $_POST[ctrl_num] ");
$res = mysql_fetch_arr ay($result);
if( $_POST[ctrl_num] = $res[0])
{
print ("Record could not be added."); print ("Item already exists.");
}
else
{
mysql_query ("INSERT INTO inventory (CTRL_NUM, PART_NUM, SHELF_BIN, UNIT_ISSUE, PART_TYPE, WHSE, VENDOR, MANUFACTUR, SYSTEM, DOM, SUB_SYS, validation, Repairstat, QAstat)
VALUES ('$_POST[ctrl_num]', '$_POST[part_num]', '$_POST[shelf_bin]', '$_POST[unit_issue]', '$_POST[part_type]', '$_POST[whse]', '$_POST[vendor]', '$_POST[manufactur]', '$_POST[system]', '$_POST[dom]', '$_POST[sub_sys]', '$_POST[validation]', '$_POST[repairstat]', '$_POST[qastat]')");
print ("Your record has been added.");
}
mysql_close();
?>
[/PHP]
still spits out the print with no errors.
[PHP]
<? include("dbconn ect.php");
$result = mysql_query("SE LECT CTRL_NUM "
. "FROM inventory "
."WHERE CTRL_NUM = $_POST[ctrl_num] ");
$res = mysql_fetch_arr ay($result);
if( $_POST[ctrl_num] = $res[0])
{
print ("Record could not be added."); print ("Item already exists.");
}
else
{
mysql_query ("INSERT INTO inventory (CTRL_NUM, PART_NUM, SHELF_BIN, UNIT_ISSUE, PART_TYPE, WHSE, VENDOR, MANUFACTUR, SYSTEM, DOM, SUB_SYS, validation, Repairstat, QAstat)
VALUES ('$_POST[ctrl_num]', '$_POST[part_num]', '$_POST[shelf_bin]', '$_POST[unit_issue]', '$_POST[part_type]', '$_POST[whse]', '$_POST[vendor]', '$_POST[manufactur]', '$_POST[system]', '$_POST[dom]', '$_POST[sub_sys]', '$_POST[validation]', '$_POST[repairstat]', '$_POST[qastat]')");
print ("Your record has been added.");
}
mysql_close();
?>
[/PHP]
Comment