Page 1 of 1

Escape Chars

Posted: Wed Dec 05, 2007 10:18 pm
by AliasBDI
I have a very strange query to run for Search Friendly URLs. My search string is "mens" which was converted from the actual title "men's". I want to compare it with a record in the database which has the data set to "Men's". So I'm making the MySQL column to replace a few characters that I remove in the search string so that the compare is the same.

In other words, a record is Men's Ministry. I convert it to use in a URL making it "mens-ministry" and it is requested by another page and then queried back to the same database table (where it is in its original form and must be converted in order to accurately be compared).

So here is my query:

Code: Select all

$query_PgDetails = "SELECT * FROM ec_Pages WHERE levelID=1 AND REPLACE(REPLACE(REPLACE(LCASE(pg_Title),' ','-'),'\'',''),'\"','')='".$ec_Page."'";
It is not working and I believe it is due to the escape character next to the apostrophe. I think that PHP thinks it should escape. This is the echo of the query:

Code: Select all

SELECT * FROM ec_Pages WHERE levelID=1 AND REPLACE(REPLACE(REPLACE(LCASE(pg_Title),' ','-'),'\'',''),'"','')='mens-ministry'
Any ideas on how to resolve this?

Posted: Thu Dec 06, 2007 10:23 am
by RobertGonzalez
Why can't you make a column in the table that houses the slug? Then you can do a 'WHERE slug = "mens-ministry"' and be done with it?