To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 08-21-2001, 03:38 AM   #1
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,366
htmlspecialcharacters help!

hi all,

i have a problem in passing characters '&'.
i use htmlspecialcharacters($subject) to pass ",',< and > and works well but it can't pass '&' sign.
for example, i need to pass the subject contains:

www.somewhere.com/discussionboard.php?subject="'<>&

and it just echoes subject="'<> (without &), which returns nothing from database.

i reeaaaally appreciate if someone can help me.

thanks.....
Anon is offline   Reply With Quote
Old 08-21-2001, 04:33 AM   #2
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,366
RE: htmlspecialcharacters help!

HI,

Normally the htmlSpecialchars() function will do the trick for the &. You could to use it with the second option like this:

htmlSpecialchars($string, ENT_QUOTES);

Else you could try it with a function like this:

function myHtmlSpecialchars($string) {
$string=eregi_replace('"','&quot;',$string);
$string=eregi_replace("'",''',$string);
$string=eregi_replace('<','&lt;',$string;
$string=eregi_replace('>','&gt;',$string);
$string=eregi_replace('&','&amp;',$string);

return $string;
}

Succes, grtz, Joris
Anon is offline   Reply With Quote
Old 08-21-2001, 04:36 AM   #3
alvin
 
Join Date: Aug 2001
Posts: 2
RE: htmlspecialcharacters help!


you can try: urlencode($subject)

alvin is offline   Reply With Quote
Old 08-21-2001, 04:46 AM   #4
marcel
Senior Member
 
Join Date: Jan 2001
Posts: 128
RE: htmlspecialcharacters help!

Maybe I'm wrong but I think that
you have to pass a URL-encoded string.

try someting like.
<?php
...
$subject='a string wih &';
echo 'www.somewhere.com/discussionboard.php?subject='.urlencode($subject);
...
?>

I hope this helps
PM
marcel is offline   Reply With Quote
Old 08-21-2001, 04:48 AM   #5
Anon
Senior Member
 
Join Date: Jun 2000
Posts: 65,366
RE: htmlspecialcharacters help!

thanks guys..

much appreciate for your help!!!
Anon is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


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








Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.