character encoding for database

As a convention I’ll make sure any PHP string used as a field value in a database query only has characters having code points below 128. Also, by convention, I will define all database string fields to be UTF-8. The place where I will be conducting the validation will be after a new string is received from a source outside my code.

The following function for adding slashes is to be used instead of addslashes() — partly because it is aware of the encoding of the characters in the string:

mysql_real_escape_string()

Read up on this function elsewhere before using it.

Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Character Encoding, Coding, Database and tagged , , , , , , , , . Bookmark the permalink.

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s