Jump to content

[SOLVED] Encoding content from a database.


JonathanV

Recommended Posts

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

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')");

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 ?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.