0

I have a text field that stores a value in database. When I input inverted commas i.e " " or apostrophe i.e. '' it automatically adds back slash to my string. How to remove back slashes or inverted commas and apostrophe?

<?php
if (empty($_POST['video_title'])) {
        $error[] = 'You must enter a video title';
    } else {
        $vid_title =  mysqli_real_escape_string($conn, $_POST['video_title']);
    }
?>
Brajman
  • 307
  • 1
  • 6
  • 16

1 Answers1

0

that is happening because of magic quotes, you should disable, if you don't want to, you can run stripslashes()

such as

<?php
if (empty($_POST['video_title'])) {
        $error[] = 'You must enter a video title';
    } else {
        $vid_title =  mysqli_real_escape_string($conn, $_POST['video_title']);
        $vid_title = stripslashes($vid_title);
    }
?>
Abdallah Alsamman
  • 1,623
  • 14
  • 22