Mysql update issue!
Syntax: [ Download ] [ Hide ] [ Select ] [ Expand ]
if (!empty($_POST['submit_1']))
{
$candidateID = $_POST['candidateID'];
require 'open_db.php';
for ($i = 1; $i <= 16; $i++) {
$word = 'resp_';
$value = $word.$i;
$response = filter_input(INPUT_POST, $value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
if (!empty($response)) {
mysql_query("UPDATE prelim_db SET $value = '" . mysql_real_escape_string($response) . "'
WHERE candidateID = '". mysql_real_escape_string($candidateID) . "' ") or die('Query failed: ' . mysql_error());
}
}
mysql_query("UPDATE prelim_db SET q_count = q_count + 1 WHERE candidateID = '$candidateID'")or die('Query failed: ' . mysql_error());
$prelim_db = mysql_query("SELECT * FROM prelim_db WHERE candidateID = '$candidateID'")
or die(mysql_error());
$row4 = mysql_fetch_array( $prelim_db );
}
mysql_close();
Now, what seems to be occurring is this:
1- it skips the 2nd response update!??
2-it takes the third response and places it in the 2nd response field in the database?
***Really screws up my questionaire form!***
What on earth is going on?!!:confused:
Does !empty cause this phenomenon ? Some one please enlighten me as to the error of my ways.
Thanks in advance,
Batoe
Last edited by cap2cap10 on Thu May 19, 2011 9:32 pm, edited 1 time in total.
The 2nd Amendment, 1789 - The Original Homeland Security.
Gun control means never having to say, "I missed you."