mysql - Error in mysql_real_escape-string function not escaping the special character -
i'm using mysql_real_escape_string function escape special character text insert info database.if utilize variable not working.
echo $ab=$_post['textarea']; when print $ab showing next text; $ab= ction throws js error we'll special charac echo $av=mysql_real_escape_string($av);
when pirnt $av showing next string
ction throws js error we'll special charac
when utilize $av value in insert query insert half test "ction throws js error we" in database. please allow me know how can prepare it.
first of please, don't utilize mysql_*
functions new code. deprecated. utilize prepared statements either pdo or mysqli.
now if stick mysql_*
extension anyway this
$ab=""; if (isset($_post['textarea']) && $_post['textarea']) { $ab = $_post['textarea']; } if (!$db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { //connection error } if (!mysql_select_db('dbname', $db)) { //error selecting db } if (!$ab = mysql_real_escape_string($ab)) { //error while escaping } $query = sprintf("insert table values('%s')", $ab); if (!mysql_query($query)) { //error executing query }
error handling code intentionally omitted brevity
mysql
No comments:
Post a Comment