PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 18th, 2012, 01:43 AM
rkrause54 rkrause54 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 rkrause54 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 51 sec
Reputation Power: 0
Question PHP5 - Need help understanding how to undo htmlspecialchars

Hi,

New to the forum and need a little help undoing the affects of some php code.

I've been told i need change $alt and $title variables after the extract($params); section in order to get image rollovers to stop showing html code in my title tag. I know it has to do the htmlspecialchars section but just don't know how to write it properly.

Can someone assist me in how i need to rewrite this code snippet to be achieve my end result of just showing the html output and not the actual source code.

Here's the code ->

Code:
extract($params); if(empty($img)) return false; if(empty($medium)) $medium = $img; if(empty($thumb)) $thumb = $img; if(empty($id)) $id = md5($img); if(!empty($title)) { $title = htmlspecialchars(htmlspecialchars_decode($title, ENT_QUOTES)); if(empty($alt)) { $alt = $title; } else { $alt = htmlspecialchars(htmlspecialchars_decode($alt, ENT_QUOTES)); } $title = " title=\"{$title}\""; } else { $title = ''; if(empty($alt)) { $alt = ''; } else { $alt = htmlspecialchars(htmlspecialchars_decode($alt, ENT_QUOTES)); } }


Thanks in advance.

Ryan

Reply With Quote
  #2  
Old November 18th, 2012, 05:40 AM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,701 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 5 h 23 m 54 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
That advice sounds suspicious. You cannot have HTML in the title attribute of anything - it has to be escaped.
Code:
Correct:   title="This word is <b>bold</b>"
Incorrect: title="This word is <b>bold</b>"

If you're using something that turns the title tooltip into some Javascript-powered thing then the problem is in whatever that Javascript is: it's using the title attribute value as text when it should be using it as HTML.

Reply With Quote
  #3  
Old November 18th, 2012, 07:48 AM
rkrause54 rkrause54 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 rkrause54 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 51 sec
Reputation Power: 0
Hi,

Your example here
Code:
Incorrect: title="This word is <b>bold</b>"


Is what is showing in my title. I need to fix it so that it just shows "This word is bold".

Please advise on how I can do that. Maybe I explained it backwards. I can give you the URL and point out what's going on if that helps.

Ryan

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Need help understanding how to undo htmlspecialchars

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap