JonathanV Posted August 22, 2009 Share Posted August 22, 2009 Hi, Small question : I'm using a mysql database running on the MyISAM engine with utf8_general_ci encoding. Now when I put something in my database ( a string perhaps .. ) or read something, do I still need to do some kind of encoding to handle special characters ? Or how is this generally handled ? Link to comment https://forums.phpfreaks.com/topic/171448-solved-encoding-content-from-a-database/ Share on other sites More sharing options...
The Little Guy Posted August 22, 2009 Share Posted August 22, 2009 I assume you want to know how to insert "Safe" strings so there is no SQL injection... If I am correct, use mysql_real_escape_string, it looks like this: $name = mysql_real_escape_string($_POST['name']); mysql_query("INSERT INTO table_name (`name`) VALUES ('$name')"); Link to comment https://forums.phpfreaks.com/topic/171448-solved-encoding-content-from-a-database/#findComment-904177 Share on other sites More sharing options...
JonathanV Posted August 23, 2009 Author Share Posted August 23, 2009 I assume you want to know how to insert "Safe" strings so there is no SQL injection... If I am correct, use mysql_real_escape_string, it looks like this: $name = mysql_real_escape_string($_POST['name']); mysql_query("INSERT INTO table_name (`name`) VALUES ('$name')"); Hi, Thanks for the information, but considering I'm working with prepared statements when inserting information into the database should I still be using this ? Link to comment https://forums.phpfreaks.com/topic/171448-solved-encoding-content-from-a-database/#findComment-904209 Share on other sites More sharing options...
gergy008 Posted August 23, 2009 Share Posted August 23, 2009 Yes. Link to comment https://forums.phpfreaks.com/topic/171448-solved-encoding-content-from-a-database/#findComment-904222 Share on other sites More sharing options...
JonathanV Posted August 23, 2009 Author Share Posted August 23, 2009 Allright, I'll add them to my code to make things just a little bit safer, thanks for the info ! Link to comment https://forums.phpfreaks.com/topic/171448-solved-encoding-content-from-a-database/#findComment-904408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.