我在将字符串“AM / PM”插入mySQL表
时遇到问题$timeFormat = mysql_real_escape_string($_POST['timeFormat']);
$sql="
UPDATE profiles
SET firstName = '$firstName', lastName = '$lastName', language = '$language', timeFormat = '$timeFormat'
WHERE profileId = '$profileId'
";
mysql_query($sql) or die('Error: '.mysql_error());
没有错误,但表格只显示AM / ??
编辑:
当我回复$ sql时,我得到了:
UPDATE profiles SET firstName = 'Johan', lastName = 'Lund', language = 'English', timeFormat = 'AM/PM' WHERE profileId = '27'
而且,是的,我在问这个问题之前很长一段时间都在网上搜索过。可能是你有任何来自Stackoverflow的链接。我已经忽略了它。
答案 0 :(得分:1)
答案 1 :(得分:0)
检查数据库中的数据类型如果它是Varchar(3),则MySQL会截断您的数据。
答案 2 :(得分:-1)
看起来斜杠在INSERT上进行某种类型的转义。我认为它被你的php解释器解释为“恶意”。
运行:
if(get_magic_quotes_gpc())
echo "Magic quotes are enabled";
else
echo "Magic quotes are disabled";
让我知道结果。