Irish SEO,  Marketing & Webmaster Discussion

 

PHP string infected with weird characters.

This is a discussion on PHP string infected with weird characters. within the Coding Help forums, part of the Webmaster Help category; Since building a simple blog tool a few weeks ago I have been wrestling with some mysterious characters that infect ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 26-02-2007, 12:59 PM
Frontpage User
 
Join Date: Oct 2006
Posts: 24
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
littleBird will become famous soon enough
Send a message via Skype™ to littleBird
Default PHP string infected with weird characters.

Since building a simple blog tool a few weeks ago I have been wrestling with some mysterious characters that infect in the users input. The user in questions is using a Windows system that for some reason enters characters like " or - in a none standard way. The result, blog entries with stuff like �

Anybody have an idea why this is happening and more crucially how I can eradicate it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 26-02-2007, 01:59 PM
kae's Avatar
kae kae is offline
Byte Wrangler
Recent Blog: prompt
 
Join Date: Sep 2006
Location: monaghan
Posts: 54
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
kae will become famous soon enough
Default

they're probably pasting from Word. Instead of producing a double-quote like ", Word has two different types for the left side and right side of a string. The "strange" hyphen (-) is probably an "em dash".

If you use the UTF-8 character set, you should see this stuff solved.
__________________
verens.com, webworks.ie
kfm.verens.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 26-02-2007, 02:04 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

It seems somebody is trying to break your website or is purelly mistake.

first you should try to convert the user input into html char() and then before insterting the data add some php functions to protect the database.

PHP Code:
$your_field htmlspecialchars($your_field);//convert html char
 
$your_field = (!get_magic_quotes_gpc()) ? addslashes($your_field) : $your_field//add magic quotes and/or slashes 
you could also use
PHP Code:
 str_replace 
function
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 10-03-2007, 03:09 AM
Frontpage User
 
Join Date: Oct 2006
Posts: 24
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
littleBird will become famous soon enough
Send a message via Skype™ to littleBird
Default

Apologise for not responding before, thank you for your advice. I have tried the various approaches suggested but have failed to resolve the issue satisfactorily.

Due to other more pressing matters and the fact that the circumstances around the data entry can be completely controlled I have opted for a human solution. Put manners on the person who was pasting their entries from MS Word.

I am sure with the aid of your suggestions I could resolve this technically but this year I am trying to learn how to avoid time holes. Those unexpected issues that become technical challenges that eat up all your time, yet must be resolved just so you can prove to yourself that you can...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 10-03-2007, 03:20 AM
georgiecasey's Avatar
Member
 
Join Date: Jul 2006
Location: Galway / Ennis
Posts: 277
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
georgiecasey will become famous soon enough
Send a message via ICQ to georgiecasey
Default

Quote:
Originally Posted by littleBird View Post
I am sure with the aid of your suggestions I could resolve this technically but this year I am trying to learn how to avoid time holes. Those unexpected issues that become technical challenges that eat up all your time, yet must be resolved just so you can prove to yourself that you can...
Lol, know exactly what you're talking about.
__________________

My Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 10-03-2007, 09:19 AM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,048
Nominated 5 Times in 3 Posts
Nominated TOTW/F/M Award(s): 1
louie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enoughlouie will become famous soon enough
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

if you are using it for textarea field, add FKeditor to it with minimum buttons and edit the javascript and where it says "force paste to plain text" change from false to true. That should help a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
characters, infected, php, string, weird

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Sponsored links

Paid On Results


All times are GMT +1. The time now is 04:59 AM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0