Computing.Net > Forums > Programming > php mysql addslashes problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

php mysql addslashes problem

Reply to Message Icon

Name: nigelt74
Date: October 29, 2006 at 19:54:58 Pacific
OS: linux, win 2k
CPU/Ram: amd 2500+ 512mb
Comment:

Hi all

I am trying to write a search query to search my MYSQL database and it works perfectly except if the search string contains an apostrophe

I have checked the database and the search terms are stored with slashes added
eg can't is stored as can\'t

Now no matter how I manipulate my query I cannot get results for those search terms that contain apostrophes, it just returns "no products found"

the query I use is

'select * from product where prod_search_term like "%'.$keyw.'%"'

I have tried adding slashes to the $keyw variable but that doesn't make a difference

Any help would be appreciated



Sponsored Link
Ads by Google

Response Number 1
Name: nigelt74
Date: October 30, 2006 at 00:26:53 Pacific
Reply:

No worries
fixed it
used the below


$keyw = str_replace("\'", "\\\\'", $keyw);
$keyw = addslashes($keyw);

I think my server may have had magic quotes on


0
Reply to Message Icon

Related Posts

See More


Java - Order of files in ... IE message



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: php mysql addslashes problem

PHP/MySQL question www.computing.net/answers/programming/phpmysql-question/9309.html

PHP/MySQL check if table exist www.computing.net/answers/programming/phpmysql-check-if-table-exist/10938.html

Cascade Combo PHP/MYSQL www.computing.net/answers/programming/cascade-combo-phpmysql/11682.html