Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse an input string to check/remove quotes 1

Status
Not open for further replies.

GreatSeaSpider

Programmer
Jul 14, 2003
70
GB
Hi all,

I've written a script to allow the manipulation of a database. It all works fine... but... the clever ppl using it are trying to use quotes ie " or ' in the text they are adding. This is causing problems as the sql query then has mis-matched quotes!

Being quite new to php (come from a java background) could anybody show me some bits of code giving examples of string parsing/manipulation in php?

would be greatly appreciated :D

Pete
 
Fortunately you are not the first to encounter this. The PHP folks have a function that escapes all offending characters:

This way you need not worry about quotes etc. and malicious arguments. It is prudent to use, because what if the user were to type:
Code:
"; DROP DATABASE mysql;
This is an extreme example, where also the access privileges would need to be really badly set. However, stuff like this is possible when you don't escape the chars.
 
Superb!

Thats just what i needed

thanks very much you have saved me from a lot of work manually parsing the string

here's a start for you

Pete
 
lets hope no user ever has that level of database access lol [noevil]

To err is human, to completely mess up takes a computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top