Current location: Hot Scripts Forums » Programming Languages » PHP » Stripslash & echo works, then doesn't


Stripslash & echo works, then doesn't

Reply
  #1 (permalink)  
Old 02-01-04, 08:24 AM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Stripslash & echo works, then doesn't

I have a db table field named "ref_term", which holds a basic product description. An example description is...

19" Designer 50/50

The descriptions are stored using the addslash function, so they are stored as...

19\" Designer 50/50

Now, I'm using 2 pages which display product info. One is prod_list.php, in which I use the "stripslash" function, and when I echo the data, the description displays fine, i.e.,

$ref_term=stripslashes($ref_term);
echo "$ref_term"

which displays as...

19" Designer 50/50

Fine so far. But on the second page, which is an edit/update page (update_product.php), I use the stripslash function, and all I get dispayed is...

19

and nothing else. If I remove the slash from the stored data, I still get the same result, meaning that nothing past the 19 is displayed.

Although this isn't the entire code, these lines must be where something isn't correct, but I don't know what.

$ref_term=stripslashes($ref_term);
Reference<br>
<input type="text" name="ud_ref_term" size="40" value="<? echo "$ref_term" ?>">

Any suggestions?
Reply With Quote
  #2 (permalink)  
Old 02-01-04, 09:51 AM
!!! HotCGIScripts !!!'s Avatar
!!! HotCGIScripts !!! !!! HotCGIScripts !!! is offline
Guru Programmer
 
Join Date: Jun 2003
Location: USA
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mdhall
I have a db table field named "ref_term", which holds a basic product description. An example description is...

19" Designer 50/50

The descriptions are stored using the addslash function, so they are stored as...

19\" Designer 50/50

Now, I'm using 2 pages which display product info. One is prod_list.php, in which I use the "stripslash" function, and when I echo the data, the description displays fine, i.e.,

$ref_term=stripslashes($ref_term);
echo "$ref_term"

which displays as...

19" Designer 50/50

Fine so far. But on the second page, which is an edit/update page (update_product.php), I use the stripslash function, and all I get dispayed is...

19

and nothing else. If I remove the slash from the stored data, I still get the same result, meaning that nothing past the 19 is displayed.

Although this isn't the entire code, these lines must be where something isn't correct, but I don't know what.

$ref_term=stripslashes($ref_term);
Reference<br>
<input type="text" name="ud_ref_term" size="40" value="<? echo "$ref_term" ?>">

Any suggestions?
If you see html source of this page you'll see:
<input type="text" name="ud_ref_term" size="40" value="19" Designer 50/50">

you should add slashes to $ref_term variable
Reply With Quote
  #3 (permalink)  
Old 02-01-04, 10:13 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
interseting bug,
how are you gonna by pass this thing!!?
I think you will have to leave the slashes in the var and notify user that he have to remove manualy !
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Query on url dihan PHP 17 01-04-04 03:47 PM
Anybody know whats wrong NerdRUS PHP 3 01-01-04 11:11 PM
bugs in publishing script bitesize PHP 0 12-02-03 10:24 PM
New Web Host, New Problem! justchat PHP 2 09-29-03 02:39 PM


All times are GMT -5. The time now is 08:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.