Posted earlier in the wrong forum...update here:
Hey there...my code below had tradtionally only updated 1 of 4 fields. Now I want to update 2 of 8, but when I enter two variables it crashes. Any help would be appreciated. Code is here
if( isset($_POST['Submit']) && $_POST['Submit']=='Submit' )
{
foreach($_POST['CFHL_A'] as $playerID=>$v)
{
//initialize to empty string and add field=value only if something was submitted
$update="";
$CFHL_A=mysql_real_escape_string( trim($_POST['CFHL_A'][$playerID]) );
$E1314_CFHL_A=mysql_real_escape_string( trim($_POST['E1314_CFHL_A'][$playerID]) );
$CFHL_B=mysql_real_escape_string( trim($_POST['CFHL_B'][$playerID]) );
$E1314_CFHL_B=mysql_real_escape_string( trim($_POST['E1314_CFHL_B'][$playerID]) );
$MFHL=mysql_real_escape_string( trim($_POST['MFHL'][$playerID]) );
$E1314_MFHL=mysql_real_escape_string( trim($_POST['E1314_MFHL'][$playerID]) );
$WFHL=mysql_real_escape_string( trim($_POST['WFHL'][$playerID]) );
$E1314_WFHL=mysql_real_escape_string( trim($_POST['E1314_WFHL'][$playerID]) );
if( !empty($CFHL_A) ) {
$update.="`CFHL_A`='".$CFHL_A."'";
}
if( !empty($E1314_CFHL_A) ) {
$update.="`E1314_CFHL_A`='".$E1314_CFHL_A."'";
}
if( !empty($CFHL_B) ) {
$update.="`CFHL_B`='".$CFHL_B."'";
}
if( !empty($E1314_CFHL_B) ) {
$update.="`E1314_CFHL_B`='".$E1314_CFHL_B."'";
}
if( !empty($MFHL) ) {
$update.="`MFHL`='".$MFHL."'";
}
if( !empty($E1314_MFHL) ) {
$update.="`E1314_MFHL`='".$E1314_MFHL."'";
}
if( !empty($WFHL) ) {
$update.="`WFHL`='".$WFHL."'";
}
if( !empty($E1314_WFHL) ) {
$update.="`E1314_WFHL`='".$E1314_WFHL."'";
}
if(!empty($update))
{
$update = 'UPDATE `playerdb` SET '. $update . " WHERE `playerID` ='".$playerID."'";
mysql_query($update) or die( sprintf('Error @Line %d while trying to execute<br/>%s<br/>%s',__LINE__,$update, mysql_error() ) );
}
}
}
// Get all the data from the "player" table
error_reporting (E_ERROR);