Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.