DrTrans Posted January 16, 2012 Share Posted January 16, 2012 $name = "D'Angelo" ok I'm running a mysql query as $query = " INSERT INTO TEST (ID, NAME) VALUES ('NULL','$NAME')"; If the name = "D'Angelo" the apostrophe would cause it to fail. Is there a way to do this without striping the characters? Quote Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/ Share on other sites More sharing options...
AyKay47 Posted January 16, 2012 Share Posted January 16, 2012 mysql_real_escape_string Quote Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/#findComment-1308252 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Use prepared statements (preferred) or escape it like AyKay said. Quote Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/#findComment-1308259 Share on other sites More sharing options...
AyKay47 Posted January 16, 2012 Share Posted January 16, 2012 Use prepared statements (preferred) or escape it like AyKay said. yes, you will need the PDO driver for prepared statements if you choose to go that route, depending on what PHP version you are running, you may or may not have the driver installed/enabled. Quote Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/#findComment-1308273 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Use prepared statements (preferred) or escape it like AyKay said. yes, you will need the PDO driver for prepared statements if you choose to go that route, depending on what PHP version you are running, you may or may not have the driver installed/enabled. Or mysqli. Quote Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/#findComment-1308275 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.