Web Design Forums

PHP

Have questions about PHP? Ask them here and our experts will assist you before you know it! You can also find help in the documentation at PHP.net.

addslashes and Firefox issue



Site of the Month Nominations
ENTER YOUR SITE NOW!

Reply
 
LinkBack Thread Tools
Old April 21 '04, 09:12 AM (#1)
ericbusch is offline
WDF's Oreamnos
 
ericbusch's Avatar
 
Join Date: August 2003
Location: Daejeon, South Korea
Posts: 241
ericbusch
addslashes and Firefox issue

I used addslashes() to display some info about a picture in the img 'alt' attribute. but on firefox when it tries to addslahes i get something like this:

...ceiling and into the \"boulder field\ This site contains...

boulder field is surrounded by quotes but when i addslashes (or for that matter when i dont use addslashes) it doesnt print the second set of quotes.

any ideas as to why that is?

eb
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 21 '04, 10:54 AM (#2)
Brak is offline
Rockstar
 
Brak's Avatar
 
Join Date: April 2003
Location: San Francisco, CA
Posts: 3,413
Brak will become famous soon enough
Send a message via ICQ to Brak Send a message via AIM to Brak Send a message via MSN to Brak Send a message via Yahoo to Brak
You can't have quotes within quotes in HTML dude, and slashes are a programming thing, not an HTML thing. I have NO clue why IE would possibly let you do this. The proper way is to do a str_replace and replace " with "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 21 '04, 10:57 AM (#3)
macgruder is offline
WDF Member
 
macgruder's Avatar
 
Join Date: April 2004
Location: Japan
Posts: 97
macgruder
Well, php is a server issue so it seems that addslashes would be affecting any kind of browser. Can you give a more detailed example. Show us the HTML not the screen output.

Remember, you only need to use addslashes before putting something into a database (or a comparable quoting situation). Adding slashes in such cases does not actually 'add slashes' - it simply prevents an error. So

'My name is o'reilly' ---> error. Hence we use
'My name is o\'reilly' ---> no error, and in the database is My name is o'reilly.

Incidently, this is why we don't need to remove the slashes later, because we didn't really add any. It was just a temporary measure.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 21 '04, 11:03 AM (#4)
filburt1 is offline
bored
 
filburt1's Avatar
 
Join Date: July 2002
Location: Maryland, US
Posts: 11,785
filburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to allfilburt1 is a name known to all
Use htmlspecialchars() on anything that is used within an attribute.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old April 21 '04, 11:33 AM (#5)
ericbusch is offline
WDF's Oreamnos
 
ericbusch's Avatar
 
Join Date: August 2003
Location: Daejeon, South Korea
Posts: 241
ericbusch
thanks everyone,

htmlspecialchars() solved the problem. i was using addslashes for outputting infor, not inserting

eric
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Web Design Forums » Programming Help » PHP

Bookmarks


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

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


 
User Infomation
Your Avatar

Site Of The Month

Ticket Cake
Ticket Cake

Ticket Cake is a drupal based event ticketing platform. It features that ability to browse events and share them.

Nominate Your Site Now!

Advertisement
WolfCMS.org

Latest Articles
- by RickM
- by bfsog

Advertisement

Partner Links



All times are GMT -4. The time now is 03:00 AM.


WebDesignForums.net is Copyright © 2010 RikeMedia.

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163