newbreed65 Posted December 30, 2008 Share Posted December 30, 2008 Hey everyone when inserting text fields into my database like a Name or News entry, i want to be able have certain characters like single quotes (", ') in the fields without breaking the MySQL Query, how would I do that? Ive done abit of research and found things like mysql_real_escape_string, addslashes, stripcslashes and quotemeta but is there a simple function like htmlspecialchars which could do it on insert for me Quote Link to comment https://forums.phpfreaks.com/topic/138824-solved-mysql-inserting-special-characters/ Share on other sites More sharing options...
trq Posted December 30, 2008 Share Posted December 30, 2008 You need to escape your data using mysql_real_escape_string providing get_magic_quotes_gpc is not returning true. If magic_quotes_gpc is however enabled (disable it if you can) you would also need to use stripslashes on your data prior to mysql_real_escape_string. Quote Link to comment https://forums.phpfreaks.com/topic/138824-solved-mysql-inserting-special-characters/#findComment-725960 Share on other sites More sharing options...
newbreed65 Posted January 1, 2009 Author Share Posted January 1, 2009 Thank you very much that works fine and sorry for the slow reply first time i got back to doing stuff because of new years Quote Link to comment https://forums.phpfreaks.com/topic/138824-solved-mysql-inserting-special-characters/#findComment-727478 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.