i need help with my code to strip white space.
its an arry update and also a insert.
this is the insert array
$INTEGER_FIELDS = array(); // as many as you need
$insert = array();
foreach($_REQUEST as $key => $value){
if($value == '') continue;
if($value == 'Submit') continue;
if($value == '685388') continue;
if($value == '12446606') continue;
if($key == 's_cc') continue;
if($key == 's_sq') continue;
if($value == '685388:12446606') continue;
if($key == 'PHPSESSID') continue;
if(in_array($key, $INTEGER_FIELDS)){
// Error checking
if(is_int($value)){
die('Error ... ['.$key.'] field does not contain an integer.');
}
$insert[$key] = $value;
} else {
$insert[$key] = "'".$value."'";
}
}
// Error checking - maybe someone just clicked the submit button.
if(count($insert)){
$sql = "INSERT into card_details (".join(',', array_keys($insert)).",date) VALUES (".join(',', array_values($insert)).",'$tdate')";
echo $sql;
mysql_query($sql) or die("Invalid query: " . mysql_error());
}
and this is my update array.
$INTEGER_FIELDS = array('property_id','security_screens'); // as many as you need
$insert = array();
foreach($_REQUEST as $key => $value){
//if($value == '') continue;
if($value == 'Submit') continue;
if($value == '685388') continue;
if($value == '12446606') continue;
if($key == 's_cc') continue;
if($key == 's_sq') continue;
if($key == 'id') continue;
if($value == '685388:12446606') continue;
if($key == 'PHPSESSID') continue;
if(in_array($key, $INTEGER_FIELDS)){
// Error checking
if(is_int($value)){
die('Error ... ['.$key.'] field does not contain an integer.');
}
//$insert[$key] = $value;
$sql_2 .= ($key.'='.$value.', ');
} else {
//$insert[$key] = "'".$value."'";
$sql_2 .= ($key."='".$value."', ");
}
}
$sql = "UPDATE card_details SET $sql_2 random = '0' WHERE id=$id" or die("Invalid query: " . mysql_error());
echo $sql;
mysql_query($sql) or die("Invalid query: " . mysql_error());
i export tables from my database into an xml, and i think the white space is stuffing up the export.
things are coming out like this.
( - = a white space)
hello welcome to the shop--------
it adds about 4 or 5 charcters of whitespace after the shop.
ok i also think & characters are throwing the xml out, how do i fix this.
cheers aron