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? 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 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. 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. 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. Link to comment https://forums.phpfreaks.com/topic/255152-strip-characters/#findComment-1308275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.