[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 12-23-2005, 11:07 PM   #1 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
 
Join Date: Apr 2004
Location: IL
Posts: 339
50.00 NP$ (Donate)

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?
__________________
Four Seasons Outfitters
[ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ]
[ 25 $NP/Month] [ 25 $NP/Month]
TwiztedFake is offline  
Old 12-23-2005, 11:16 PM   #2 (permalink)
Senior Member
 
Join Date: Nov 2005
Location: Hong Kong
Posts: 1,150
2,523.40 NP$ (Donate)

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.
__________________
-----------------------------------------------------
|-----FREE BANNER EXCHANGE! 1:1 RATIO!!!!-----|
|-------------www.bannercenter.info-------------|
-----------------------------------------------------
aznchong91 is offline  
Old 12-24-2005, 12:54 AM   #3 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

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, 08:14 AM   #4 (permalink)
NamePros Regular
 
TwiztedFake's Avatar
 
Join Date: Apr 2004
Location: IL
Posts: 339
50.00 NP$ (Donate)

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.
__________________
Four Seasons Outfitters
[ 25 $NP/Month ] [ 25 $NP/Month ] [ 25 $NP/Month ]
[ 25 $NP/Month] [ 25 $NP/Month]
TwiztedFake is offline  
Old 12-24-2005, 08:40 AM   #5 (permalink)
mch
NamePros Regular
 
Join Date: Nov 2005
Location: EU
Posts: 248
99.25 NP$ (Donate)

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

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


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 07:51 PM
Problem with PHP monRa Programming 15 09-12-2005 04:28 AM
local server installations, urgent help needed. Porte Web Hosting Discussion 1 06-23-2005 03:05 PM
PHP Problem on a website? aal814 Web Design Discussion 1 12-29-2004 10:53 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 05:15 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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