开发者

problem with inserting a forward slash in mysql table

I got problem inserting the string "AM/PM" to my mySQL table

$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());

There is no error, but the table is only showing AM/ ??

Edit:

When I echo the $sq开发者_如何学编程l I get:

UPDATE profiles SET firstName = 'Johan', lastName = 'Lund', language = 'English', timeFormat = 'AM/PM' WHERE profileId = '27'

And, yes I have searched the web in a very long time before asking this question. Probably if you have any link from Stackoverflow. I have already overlooked it.


nothing wrong with this insert.
it's matter of how do you see the query result.


Check your datatype in the database If it's Varchar(3) then MySQL is truncating your data.


Looks like that slash is doing some type of escape upon INSERT. I assume its being interpreted as "malicious" by your php interpreter.

Run this:

if(get_magic_quotes_gpc())
echo "Magic quotes are enabled";
else
echo "Magic quotes are disabled";

Let me know the result.


Check your character set and collation for the table, I was able to fix this with a TEXT column if it is utf8 charset and utf8_bin collation, whereas latin1 was truncating after the forward slash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜