RyanSF07 Posted February 5, 2008 Share Posted February 5, 2008 Hi All, I'm using addslashes to add slashes to the string: What's her dog's name? before inserting to the database. I can retrieve it correctly with: $id = $row["id"]; $question = $row["question"]; $question2 = stripslashes($question); and echoing $question2. The user then has the option to "update" or change their question. Clicking "edit" take them to another php page where I'm using: $id = $_GET[id]; $update = $_POST['update']; $question = $_POST['question']; and retrieving that same string with: <?php echo stripslashes($myrow["question"]); ?> However, this doesn't work. Instead of getting: What's her dog's name? I get: What ... everything after the first apostrophe is deleted. what am I doing wrong here. Isn't stripslashes("my string") supposed to strip the slash WITHOUT deleting the rest of the string? :-\ Thank you very much for your help, Ryan Quote Link to comment Share on other sites More sharing options...
RyanSF07 Posted February 5, 2008 Author Share Posted February 5, 2008 Here's the full chunck of code that is supposed to grab and enable the edit: <?php $id = $_GET[id]; $update = $_POST['update']; $question = $_POST['question']; if($id) { $sql = "SELECT * FROM $table WHERE id=$id"; $query_result = mysql_query($sql); $myrow = mysql_fetch_array($query_result); $_SESSION[editQ] = $id; ?> Edit this question. <form action="edit_this_q_processor.php?id=$_SESSION[editQ]" method="post"> <input type="hidden" name="id" value="<?php echo $myrow[id]?>"> <b>Question:</b><br> <input type="Text" name="question" value='<?php echo stripslashes($myrow["question"]); ?>' size="50"> .... Thanks again for your help, Ryan Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted February 5, 2008 Share Posted February 5, 2008 try replacing "question" with 'question' Quote Link to comment Share on other sites More sharing options...
revraz Posted February 5, 2008 Share Posted February 5, 2008 Sounds like the edit page is not adding slashes back in. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 5, 2008 Share Posted February 5, 2008 On this line: <input type="Text" name="question" value='<?php echo stripslashes($myrow["question"]); ?>' size="50"> change the single quotes to double quotes: <input type="Text" name="question" value="<?php echo stripslashes($myrow["question"]); ?>" size="50"> When you have the single quotes, the single quote in the string being echoed is being taken for the string end. If you do a "show source" you will see the whole string there. Ken Quote Link to comment 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.