I am having trouble formatting a string of data to go into an HTML input field. Here's my query:
$sql_active = "SELECT * FROM table WHERE id='$id'";
$result_active = $mysqli->query($sql_active);
$row = mysqli_fetch_array($result_active);
$job_description = stripslashes($row['job_description']);
I then use the $job_description variable to show the information on the page. Later on the page, I've got a hidden form field that I need put the information in as well. So then I do this:
<input type="hidden" name="description" value="<?php echo $mysqli->real_escape_string($job_description); ?>" />
The problem is that when the user first inputs the description field, they can use quotes, double quotes, etc. (whatever they would like). In this one example I've got here, it's not allowing for the information to go past the quotation marks. Its shows up like this:
<input type="hidden" name="description" value="PLEASE NOTE: YOU MUST HAVE EXPERIENCE\r\n\r\nOne of the city\'s best employers. Basic \" handyman\" repair skills preferred. ">
When it hits the first apostrophe, it escapes it but then because the user has used both a apostrophe AND a quotation mark, it gets confused.