PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Apr 12, 2005 5:34 am
Hi all,
I pass variables to a query which can have a ' in them depending what the user has entered. How can i make the query escape the ' in the query.
Code: Select all
<?php
select mhvid from tbl_master_ho_invoice where mhv_location = 'Helen's Kingdom'
?>
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Tue Apr 12, 2005 6:46 am
Use
addslashes() and it'll autmatically convert all ' to \'
gurjit
Forum Contributor
Posts: 314 Joined: Thu May 15, 2003 11:53 am
Location: UK
Post
by gurjit » Tue Apr 12, 2005 6:51 am
cheers anjanesh, worked wonders