M4verick Posted April 2, 2010 Share Posted April 2, 2010 Hello all. I've had a question regarding some data I'm trying to store in MySQL. I'm creating a basic trouble ticketing system for some php/mysql practice. When someone posts some data, if it has ' or " in it, it goes through fine. However, I tried to make it that when it is updated, it appends the new stuff to the end of the old stuff. However, it loses the chunk of data where the ' or " is at. I had been using mysql_real_escape_string() to store the data. But when I call it for viewing, I see more characters added (r\n\. The magic_quotes_gpc is disabled in the php.ini Despite the extra characters, when I append the new info to the variable with the old information, if there are any more ' or " and commas, then it cuts of a chunk of the old data, and the new information is stored just fine. Repeat as information is added. So, what am I doing wrong here? This is how I'm storing it originally. I just throw $prob in the database. $prob = mysql_real_escape_string($_POST['prob']); Everytime after that is done like this - $poster = $_SESSION['username']; $lasttouched = $poster."/".date("D M j G:i:s T Y"); $oldbody = mysql_real_escape_string($_POST['body']); $newbody = mysql_real_escape_string($_POST['bodyupdate']); $updatebody = $oldbody."<p />".$lasttouched." - ".$newbody; $body = mysql_real_escape_string($updatebody); Which I then send $body to the database. I did try adding stripslashes() to the data it restores, then it appends the new data, and redoes the mysql_real_escape_string() Is this wrong? I'm finding a lot of conflicting information. Quote Link to comment https://forums.phpfreaks.com/topic/197335-mysql-storing-quotes/ Share on other sites More sharing options...
ignace Posted April 2, 2010 Share Posted April 2, 2010 htmlentities Quote Link to comment https://forums.phpfreaks.com/topic/197335-mysql-storing-quotes/#findComment-1035817 Share on other sites More sharing options...
M4verick Posted April 2, 2010 Author Share Posted April 2, 2010 Ok, htmlentities ($str, ENT_QUOTES); And html_entitiy_decode($str) brought me a step further, but something is still not entirely right. Looks like it removes backslashes. Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/197335-mysql-storing-quotes/#findComment-1035996 Share on other sites More sharing options...
M4verick Posted April 3, 2010 Author Share Posted April 3, 2010 Scratch that, I was able to get it to work, I had more issues that I had to resolve. Thank you kindly. So for clarification if any posters in the future regard this thread... Run this for sending it do the database - htmlentities($string, ENT_QUOTES); And this for retrieving - html_entity_decode($string); Quote Link to comment https://forums.phpfreaks.com/topic/197335-mysql-storing-quotes/#findComment-1036316 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.