Jump to content

Recommended Posts

I'm getting errors because of apostrophes when I try to insert text into a mysql field. I'm getting the text is coming from POSTing a textarea from a previous page. I've tried a few things like addslash() but I'm not sure how to keep it from messing with the mysql syntax. I know there has to be an easy way to do this though. I appreciate any help, thank you.

Link to comment
https://forums.phpfreaks.com/topic/146129-solved-inserting-textarea-into-mysql/
Share on other sites

mysql_real_escape_string the text coming from forms being inserted into the DB.

 

addslashes is being depreciated and suggested not to be used.

 

Post the spot where you are inserting if the mysql escape string does not solve this, as chances are you are probably using it wrong.

I'm still having the same problem, I'll post my code:

$review = mysql_real_escape_string($_POST['review']);
$sql="INSERT INTO Reviews (Title, Rating, Review) VALUES('$_POST[title]','$_POST[rating]',$review)";

 

The error I'm getting is: 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 'For one of the few times

 

This is the first words of the textarea I'm trying to put in the database. (minus the ' before "For") This means that it is getting the textarea and putting it in $review but is it putting a ' at the beginning?

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.