Forum Moderators: coopster
// Connect to database etc., then:
// ESCAPE CHARACTERS
$comments = $_POST['comments'];
$comments = mysql_real_escape_string($comments);
// I assume I would do this for all input fields where text or numbers can be filled in such as inputs for an email address and age?
// Insert the data from form
$sql="INSERT INTO tablename (
FieldOne,
FieldTwo,
Comments)
VALUES (
'$_POST[FieldOne]',
'$_POST[FieldTwo]',
$comments)";
// Run mysql_query()
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\r\n \r\n\'Single quotes\'\r\n\r\n\"Double\"\r\n\r\n/ Slashes\r\n// Double slash' at line 27 function webify($input) {
$symbols = array(
'/&/' => '&',
'/[\\\\]{1}\'/' => ''',
'/[\\\\]{1}"/' => '"',
'/</' => '<',
'/>/' => '>',
'\'' => ''',
'"' => '"'
);
foreach($symbols as $symb => $repl) {
$input = preg_replace($symb, $repl, $input);
}
return $input;
}