Jump to content

Using special characters in mysql entries.


elmas156

Recommended Posts

OK, first let me say that I'm testing locally, using MYSQL version 5.1.36

 

I'm creating a site that is designed to me sort of an internal messaging system much like email but messages will only be able to be sent to other users within the system.  I've created a page to insert the message information into the database to be retrieved later and everything works perfectly until I use special characters that might normally be used in a message, such as apostrophes ( ' ).  The type of field is set as varchar 20000.  This is the only way that I know how to do it as I am learning as I progress.  What can I do to get mysql to accept the message, including the special characters that are used?  Also, is there a better field type I should be using?  Thanks in advance for any help.

 

This is the error that I get when a special character is used:

 

Notice: Undefined index: grade in C:\wamp\www\insertmsg.php on line 40

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'm going to see if this works.')' at line 1

All string data values put into a query must be escaped so that any special sql characters in the data don't break the sql syntax and to prevent sql injection by hackers.

 

See this link - mysql_real_escape_string

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.