php - Escaping a single quote in a variable before Insert -
here's how insert code looks:
$values .= ($ta->account_toll_free_number != '') ? ",('" . $post_id . "', 'toll_free_number','" . $ta->account_toll_free_number . "')" : null;
which gives me:
(111, 'toll_free_number', '888-123-1234')
which works great until there single quote mark in variable. breaks. there someway can clean/escape before this? need swap single quotes double quotes?
i did way. started output , added single quote last part.
$values = mysql_real_escape_string("(111, 'toll_free_number', '888-'123-1234')"); $query = "insert yourtable (fieldname) values ('".$values."')"; mysql_query($query) or die(mysql_error());
see more manual http://php.net/manual/en/function.mysql-real-escape-string.php
Comments
Post a Comment