Jump to content

Php Coding And Mysql Database Table Character Help


ianhaney

Recommended Posts

Hello

 

I have got a feedback form on my website that when a customer writes a testimonial it gets automatically added to my testimonials.php page but have noticed that if a customers writes the word can't for example, the testimonial is not displayed on the website and is not being added to the database table either due to the character ' in the word betwen the n and t and have found out it is to do with the following line I think

 

$query    =    "insert into testimonials(name,testimonial)values('$name','$testimonial')";

 

How would I change that line or insert a bit of coding so that characters like ' and others are displayed when words that have them characters in are added to the database table

 

Kind regards

 

Ian

Link to comment
Share on other sites

Read up on mysql_real_escape_string () (or Prepared Statements with MySQLI), you can find it in the PHP manual.

 

Your scripts are currently wide open to SQL injection attacks, and you need to read up on form submissions security. More specifically output escaping and input validation.

Sverre H. Huseby's "Innocent Code" is a very good book on this subject.

Link to comment
Share on other sites

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.