Inserting data from a <form> into MySQL w/ PHP?

travo

New member
MySQL keeps giving me a syntax error and will not insert any data (that comes from a textarea form) if it has an apostrophe (single quote) in it. I'm pretty sure there is some function that I need to run the data through before attempting to insert it into MySQL DB.

Anyone know what function I need to use here? The data I'm using is coming from a textarea form and gathered with the $_POST function.

Current script..

$data= $_POST['data'];

then...

$query = "INSERT INTO mytable (data) " .
" VALUES ('$data')";

$result = mysql_query($query);

Appreciate the help and I'm sure this is an easy one for someone with little to moderate php/mysql experience
 
Back
Top