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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.