How can I avoid the quote when getting a record from the database?

I am adding records to my database with the $wpdb

following:

$title = 'test url';
$content = '<a href="#">test</a>'
$wpdb->insert($db_name, array(
   "title" => $title,
   "content" => $content
), '%s');

      

when i check the database i can see that the content is accepting a backslash with quotes like this: <a href=\"#\">test</a>

I tried to get the record from the database using stripcslashes()

, but dosnt work.

Is there a way to do this for security reasons too?

+3


source to share


2 answers


Please get the record from the database and pass it to this function



$without_slashes = stripslashes($row['coln']);

      

+2


source


try it



$title = 'test url';
$content = "'<a href=\"#\">test</a>'"
$wpdb->insert($db_name, array(
   "title" => $title,
   "content" => $content
), '%s');

      

0


source







All Articles