Deathwillow Posted December 10, 2008 Share Posted December 10, 2008 Alright, so I've been trying to search the web looking for a way around this but haven't had any luck. So I'm working on a new script and whenever I use words like "I'm, or I've" basically anything with a ' in it I get an error... Was wondering if there's a way around this as clearly people would want to use correct punctuation when posting news and information: My current code for entering items into the database: <?php $sql = mysql_query("INSERT INTO news VALUES ('','".$today."','".$title."','".$blog."','".$author."','".$icon."')"); ?> Link to comment https://forums.phpfreaks.com/topic/136349-solved-using-a-in-an-insert-statement/ Share on other sites More sharing options...
swamp Posted December 10, 2008 Share Posted December 10, 2008 mysql_real_escape_string($today); etc.. Link to comment https://forums.phpfreaks.com/topic/136349-solved-using-a-in-an-insert-statement/#findComment-711334 Share on other sites More sharing options...
pea Posted December 10, 2008 Share Posted December 10, 2008 http://www.php.net/addslashes ? Link to comment https://forums.phpfreaks.com/topic/136349-solved-using-a-in-an-insert-statement/#findComment-711335 Share on other sites More sharing options...
PFMaBiSmAd Posted December 10, 2008 Share Posted December 10, 2008 Addslashes does not escape all the special characters that can break a query. Link to comment https://forums.phpfreaks.com/topic/136349-solved-using-a-in-an-insert-statement/#findComment-711338 Share on other sites More sharing options...
Deathwillow Posted December 10, 2008 Author Share Posted December 10, 2008 http://www.php.net/addslashes ? Thanks, even found a useful function that does this. Link to comment https://forums.phpfreaks.com/topic/136349-solved-using-a-in-an-insert-statement/#findComment-711342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.