I am having trouble submitting form data to my mysql database. Mysql/Php seems to be treating the open and closed quotes (a.k.a. “ and ”) differently from other characters such as your regular (") or even (<) (>) or (&).
What gets submitted to my database is “ and ” and I don't want that. I want open and closed quotes to appear just like any other character. What is odd is that if I hit the "back button" on my browser and resubmit the same post, I will get what I want submitted to my database. But I want the (“) and (”) to submit correctly on the first try.
I haven't tested all characters to see which work and which don't, but I have tested some and it appears only the open and closed special quotes are the only ones giving trouble.
Here is my query structure:
$content = mysql_real_escape_string($_POST['content']);
$topictitle = mysql_real_escape_string($_POST['topictitle']);
$topiccategory = mysql_real_escape_string($_POST['topiccategory']);
$date = date('Y-m-d H:i:s');
$query = "INSERT INTO `ttable` (`topictitle`,`user`,`cat`,`postcontent`,`posttime`,`replylast`) VALUES ('".$topictitle."','".$_SESSION['user']."','".$topiccategory."','".$content."','".$date."','".$date."')";
My form is really long and I dont think it will be relevant so I won't post that.
Any idea what might cause this behavior?
Note: mysql_real_escape_string does not seem to be escaping the open/close quotes...
Update: Changing my method to "get" instead of "post" so I can see my view source...the $_GET['content'] view source shows the code, not the quote. So something must be happening before I even get to the mysql query page. I still can't see why it converts the special quote to a code. I haven't done anything to it.
UPDATE2: I put a string_replace in right before the mysql query and right after the mysql_real escape string. I figured that I could at least replace all instances of “ and ” with left and right quotes again. Instead, now what I get in my database is....“ and †... so there's definitely something funny goin on...
UPDATE3: UPDATE2 was missing the fact that I put this (
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
) at the head of my page when that happened.
UPDATE4: This looks like a similar problem, but doesnt fix mine. Putting the meta tag at the top of the pages creates a new problem where special quotes get turned into “ and †... I should perhaps note that I am on a mac.