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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Escaping Characters in PHP and MySQL

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
0
0
US
I'm having trouble with a very simple SQL statement to find a certain string within a body of text:

Code:
SELECT ID FROM mainpages WHERE BodyText LIKE [COLOR=red]'%<!--ImageBegin->%'[/color] AND ID = 10

No matter how I escape the characters in it, it isn't found even though it's there. Any ideas?

Don
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
This seems to have done the trick:

Code:
SELECT ID FROM mainpages WHERE BodyText LIKE [COLOR=green]'%" . mysql_real_escape_string('<!--ImageBegin-->') . "%'[/color] AND ID = 10

Don
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top