elderclann Posted April 23, 2009 Share Posted April 23, 2009 I have a standard form using an <input> tag. I am entering quotes into this field and updating my database. When the text is updated into the data base the quotes hava a \ in front of them. I've tried double quotes, single quotes, inserting the \ and it always updates incorectly. Here is the php code I'm using to update the db any help is greatly appreciated. <code> $query = "Update tblEvents set eventDate = '" . $eventDate . "', eventTime = '" . $eventTime . "', eventTitle = '" . $eventTitle . "', eventLocation = '" . $eventLocation . "', eventDescription = '" . $eventDescription . "', showOnWeb = '" . $showOnWeb . "' where eventID = " . $eventID; </code> Quote Link to comment https://forums.phpfreaks.com/topic/155348-solved-update-with-quotes/ Share on other sites More sharing options...
revraz Posted April 23, 2009 Share Posted April 23, 2009 $query = "Update tblEvents set eventDate = '$eventDate', eventTime = '$eventTime', eventTitle = '$eventTitle', eventLocation = '$eventLocation', eventDescription = '$eventDescription', showOnWeb = '$showOnWeb' where eventID = $eventID; Quote Link to comment https://forums.phpfreaks.com/topic/155348-solved-update-with-quotes/#findComment-817282 Share on other sites More sharing options...
MadTechie Posted April 23, 2009 Share Posted April 23, 2009 The problem is likely due to Magic Quotes are being on your need to use stripslashes, but that opens a security hole.. so try this <?php if(get_magic_quotes_gpc()) { $eventDate = stripslashes($_POST['eventDate']); $eventTime= stripslashes($_POST['eventTime']); $eventTitle = stripslashes($_POST['eventTitle']); $eventLocation = stripslashes($_POST['eventLocation']); $eventDescription = stripslashes($_POST['eventDescription']); $showOnWeb = stripslashes($_POST['showOnWeb']); $eventID = stripslashes($_POST['eventID']); } else { $eventDate = $_POST['eventDate']; $eventTime= $_POST['eventTime']; $eventTitle = $_POST['eventTitle']; $eventLocation = $_POST['eventLocation']; $eventDescription = $_POST['eventDescription']; $showOnWeb = $_POST['showOnWeb']; $eventID = $_POST['eventID']; } $query = sprintf("Update tblEvents set eventDate = '%s', eventTime = '%s', eventTitle = '%s', eventLocation = '%s', eventDescription = '%s', showOnWeb = '%s' where eventID = %d", mysql_real_escape_string($eventDate), mysql_real_escape_string($eventTime), mysql_real_escape_string($eventTitle), mysql_real_escape_string($eventLocation), mysql_real_escape_string($eventDescription), mysql_real_escape_string($showOnWeb), $eventID ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/155348-solved-update-with-quotes/#findComment-817284 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.