Re: Qoute problem

From: Date: Thu, 15 Feb 2001 04:59:44 +0000
Subject: Re: Qoute problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39822@lists.php.net to get a copy of this message
use stripslashes() in the submit page to take care of the problem with the quotes for ex, if the name of the textbox for description is "txtDesc", use the following line at the top of the page $describe=stripslashes($describe); so your code will look like PHP Script #1: Editing description print' </textarea><br> Description:<br><textarea name=describe cols=40 rows=10>'; echo $info["description"]; print' </textarea><br>'; PHP Script #2: (preview changes) <input type=hidden name=describe value="<?php print stripslashes($describe)?>"> <b>Description:</b><br> <?php print stripslashes($describe) ?> <p> PHP Script #3: (update database) $describe=stripslashes($describe); $sql = "UPDATE news SET release_date='$date', title='$title', description='$describe', contact='$contact', content='$test', type='$type' WHERE news_id=$id"; $result = mysql_query($sql) make sure that you make use of stripslashes in both the pages ( in the hidden field of the second page as well) otherwise you will have to use multiple stripslashes() calls to get back to your original data hope that halps best regards Ankur Verma HCL Technologies A1CD, Sec -16 Noida, UP India ----- Original Message ----- From: "Tanya Brethour" <brethour@ncsa.uiuc.edu> To: <php-general@lists.php.net> Sent: Wednesday, February 14, 2001 10:26 PM Subject: [PHP] Qoute problem > > Hi! I was hoping that someone could help me out. I am not positive if I > understand whats going on.. so let me try to explain. > > This is a process to modify news articles in a MySQL database. > > (From the point after picking the article to modify) > PHP Script #1: > I grab everything from the database and stick it into the HTML form > (textarea, text, etc). I allow the user to modify whatever they want. > > PHP Script #2: > This script takes the new information and displays it to the user.. it is > a preview of what it will look like with the changes. > > PHP Script #3: > Updates the news article in the database. > > Now the problem I am having.. is that the description and content fields > have qoutes in them. For example: > Description: I like to run and walk. I love "smelly cheese." > > So.. when it tries to update the database. It will only store this as the > description: > I like to run and walk. I love\\ > > I know that its because the qoutes are not being escaped correctly.. and > it seems as though it is escaping the escape. > > So my question is.. how can I keep my qoutes? > > Just FYI.. I am making the user enter in the description and content in > html. So i cant just change the qoutes to HTMLTags because it would change > my <P> and <a href=> etc. > > Below is an example of the code (shortened for an example): > > PHP Script #1: Editing description > > print' > </textarea><br> > Description:<br><textarea name=describe cols=40 rows=10>'; > echo $info["description"]; > print' > </textarea><br>'; > > PHP Script #2: (preview changes) > > <input type=hidden name=describe value="<?php print $describe?>"> > <b>Description:</b><br> > <?php print $describe?> <p> > > PHP Script #3: (update database) > $sql = "UPDATE news SET release_date='$date', title='$title', > description='$describe', contact='$contact', content='$test', > type='$type' > WHERE news_id=$id"; > $result = mysql_query($sql) > > > Thanks in advance. > > -Tanya > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#39822) next »