My same script works on another page, and the other queries on the same page are using the same connection string. For some reason when I run the 'filled' condition it says my connection string is null. "mysql_query() expects parameter 2 to be resource, null given in..." Yet if I run the 'filled2' condition it executes just fine. Can anyone see what I don't?
if (isset($_POST['filled'])) {
function updateRecords($varA,$varB,$varC){
$updateMyTable = "UPDATE myTable SET colA='$varA', colB=$varB WHERE colC = $varC";
if (!mysql_query($updateMyTable,$con)) {
die('Error 1: '. mysql_error());
}
}
if ( isset( $_POST['inputArray'] ) ) {
foreach ( $_POST['inputArray'] as $lilVars ) {
updateRecords($lilVars['inputA'],$lilVars['inputB'],$lilVars['inputC']);
}
}
} elseif (isset($_POST['filled2'])) {
$sqlAddRecord="INSERT INTO myTable (ColX, ColY, ColZ2) VALUES ($VarX,'$VarY',$VarZ)";
if (!mysql_query($sqlAddRecord,$con)) {
die('Error 2: '.mysql_error());
}
echo "New Record Added";
}