characters issue in my sql

hi there,
i am facing some issues while putting some special characters like <> sign in mysql. Even if i pushed a value of a multiline text box with some hard enters, it doesn’t observe that and add that text without line breaks. I am using htmlentities($myVal,ENT_QUOTES); while inserting the record. In sql i have given LONGTEXT datatype to the field as the value may contain a good number of words in it.
Please tell me what should i do. One more thing, if i put something with “” it will add slashes before that in mysql and shows that while fetching the data to browser :(.

Pls. tell me if you need any further info from me.


what i am doing is preformating my get values 1. making all linefeeds unix style linefeeds 2. undoing gpc_magic qoutes.
function prepare_input(&$var)
foreach($var as $key => $value)
if(get_magic_quotes_gpc()) $var=stripslashes($var);
$var=str_replace(“rn”,“n”,$var); //windows linefeeds
$var=str_replace(“r”,“n”,$var); //mac linefeeds

// uncomment needed

the u have to be careful with all further operations:
mysql_query( ‘UPDATE table SET id= "’.intval($POST[‘id’]).’", field1="’.mysql_escape_string($POST[‘field1’]).’" WHERE field2 LIKE "%’.str_replace(’%’,’%’,str_replace(’’,’’,mysql_escape_string($_POST[‘field2’]))).’%"’ );

echo ( ‘

’.nl2br(htmlentities($_POST[‘text’])).’’ );

hope this answerd all of ur question

Sponsor our Newsletter | Privacy Policy | Terms of Service