1
TheFinni
addSlashes in edit form variable?
  • 2004/10/28 20:38

  • TheFinni

  • Just popping in

  • Posts: 75

  • Since: 2003/11/25


I recently noticed a problem when editing one of my articles.

If I save something to the database such as:

That 70's show

The item is saved properly...

However when I try to edit the article, whatever was after the ' (tickmark) will not show. I.e That 70

I assume it has something to do with this XOOPS form element code:

Quote:
$sform -> addElement( new XoopsFormText( 'Favorite TV Show:', 'favoritetvshow', 50, 80, $favoritetvshow) );


I tried this:

Quote:
$sform -> addElement( new XoopsFormText( 'Favorite TV Show:', 'favoritetvshow', 50, 80, addSlashes($favoritetvshow)) );


But it only gave me:

That 70\

How can I get the addSlashes PHP code in the retrival of this entry? It is used in the saving process.
I am using the News module but have added my own custom field.

Thanks!

~Thomas

2
highlander
Re: addSlashes in edit form variable?
  • 2005/12/29 20:55

  • highlander

  • Not too shy to talk

  • Posts: 151

  • Since: 2004/12/5


Might be an old post but I ran into the same problem today.

I solved it by doing the following:
htmlspecialchars($contentENT_QUOTES)

instead of :
addslashes($content)


and to get the content back :
unhtmlentities($content)


and the function unhtmlentities is as follows :
function unhtmlentities ($string) {
   
$trans_tbl =get_html_translation_table (HTML_ENTITIES );
   
$trans_tbl =array_flip ($trans_tbl );
   return 
strtr ($string ,$trans_tbl );
}


greetings Highlander
So, I'm in the park wondering why frisbees get larger as they get closer when suddenly, it hits me...
www.AnimalPedigree.com

3
Catzwolf
Re: addSlashes in edit form variable?
  • 2005/12/29 21:04

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


There are functions with XOOPS to handle slashes (as there are function within php to handle these)

You could use $myts class like thus

$myts = &MyTextSanitizer :: getInstance();

While saving text
$your_text = $myts ->addslashes($text);

When displaing text
$your_text = $myts->htmlSpecialChars($myts ->stripSlashesGPC($text ));

Should be enough to do what you where trying to do.

Login

Who's Online

174 user(s) are online (107 user(s) are browsing Support Forums)


Members: 0


Guests: 174


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits