Jump to content

Match % character in WHERE clause


nickdrums

Recommended Posts

I have written a simple PHP script which is matching bank payment references to those stored in a simple table to allocate payments. All is fine until the script tries to match the reference:

FROST DD %0 NC

It is the % sign which is confusing things. The exact query is as follows:

SELECT t1.*, t2.* FROM ds_references AS t1, ds_tutors AS t2 WHERE t1.reference = 'FROST DD %0 NC' AND t1.tut_id = t2.tut_id

This exact query executed through phpmyadmin does return the correct record, but using my PHP script returns no records.

 

I have tried escaping the % character with a single quote, a backslash and another % character, to no avail. I've also tried passing the reference through mysql_real_escape_string but still no good.

 

The query works fine for all other references.

 

Can anyone help me see what I'm missing?

 

 

Link to comment
https://forums.phpfreaks.com/topic/210933-match-character-in-where-clause/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.