我尝试插入到表中一些值,但我有一个问题。字段 key1、key2、key3、key4 中有不必要的字符 (\n)。这是一个例子:
INSERT INTO questions (`key1`,`key2`, `key3`, `key4`, `user_id`, `creation_date`, `taksi`, `type`, `permission`)
VALUES ('\n17','\n18','\n19','\n20','5','2012-12-18 14:37:31', '1', 'multiple_choice', '0')
我怎样才能避免 \n ?
原始代码:
$user_id = $_SESSION['id'];
$key1 = mysql_real_escape_string($_GET['key1']);
$key2 = mysql_real_escape_string($_GET['key2']);
$key3 = mysql_real_escape_string($_GET['key3']);
$key4 = mysql_real_escape_string($_GET['key4']);
$taksi = mysql_real_escape_string($_GET['taksi']);
$permission = mysql_real_escape_string($_GET['permission']);
$sql = "INSERT INTO questions (`key1`,`key2`, `key3`, `key4`, `user_id`, `creation_date`, `taksi`, `type`, `permission`)
VALUES ('".$key1."','".$key2."','".$key3."','".$key4."','".$user_id."','".$today."', '".$taksi."', '".$type."', '".$permission."')";
mysql_query($sql);