NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Another PHP problem

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-24-2005, 12:07 AM THREAD STARTER               #1 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
Join Date: Apr 2004
Location: IL
Posts: 348
TwiztedFake is on a distinguished road
 



Another PHP problem


I'm writing my first major site using a database and php. Of course I keep running into things I don't know yet. So here is my latest problem. I'm working on an article submission and get an error anytime there is a ' , " : ; and other common punction. I know I need to do something in the processing part of the code.

Help please?
__________________
-TwiztedFake-
RTard Tutorials
Digital-Dummy to Total-Techie
TwiztedFake is offline  
Old 12-24-2005, 12:16 AM   #2 (permalink)
Senior Member
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,154
aznchong91 is a jewel in the roughaznchong91 is a jewel in the roughaznchong91 is a jewel in the rough
 



put a \ infront of each special character.
__________________
If you're as bored as I am, join me in Fallensword!
(I swear, this game is actually pretty fun :P)
aznchong91 is offline  
Old 12-24-2005, 01:54 AM   #3 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
if the error is occuring when you try and input them into the database you can use mysql_real_escape_string() if you are using mysql (there are similar functions for other databases)

In addition if the string is to be displayed on a web page then you could also run it through htmlentities() which will stop the browser processing any html instead of displaying it.
Peter is offline  
Old 12-24-2005, 09:14 AM THREAD STARTER               #4 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
Join Date: Apr 2004
Location: IL
Posts: 348
TwiztedFake is on a distinguished road
 



Quote:
put a \ infront of each special character.
That doesn't solve the problem when I'm using an input field that members will be able to write in. I use that in my hard coding of course to take care of situtaions like I stated on my side. I can't expect members of my site to put \ in front on all special characters when the type up an article.

Quote:
if the error is occuring when you try and input them into the database you can use mysql_real_escape_string() if you are using mysql (there are similar functions for other databases)
Thats what I was thinking but thought there might be a better way of doing it. Thanks for the help guys.
__________________
-TwiztedFake-
RTard Tutorials
Digital-Dummy to Total-Techie
TwiztedFake is offline  
Old 12-24-2005, 09:40 AM   #5 (permalink)
mch
NamePros Regular
Join Date: Nov 2005
Location: EU
Posts: 248
mch is on a distinguished road
 



Yeah you just need to escape the string or convert those characters to XHTML entities.
mch is offline  
Closed Thread


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Annual Christmas Sale @ Erudnet | Hot Deals | PHP 5 HOSTING! iNod Web Hosting Offers 0 12-01-2005 08:51 PM
Problem with PHP monRa Programming 15 09-12-2005 05:28 AM
local server installations, urgent help needed. Porte Web Hosting Discussion 1 06-23-2005 04:05 PM
PHP Problem on a website? aal814 Web Design Discussion 1 12-29-2004 11:53 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:11 PM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger