I need to store the values of a textarea tag using a form to submit the value and finally store to a mysql database table. Here is what I have, I am sure its something dumb, but its been a while since I have used php.
<?php
if(isset($_POST['submit'])){
$con = mysql_connect ('localhost','username','password') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());
//$desc = mysql_real_escape_string($_POST['txtDesc']);//nl2br($_POST['txtDesc']);
$desc = mysql_real_escape_string($_POST['txtDesc']);
$sql = "INSERT INTO desc_tbl (desc) VALUES('$desc')";
$result = mysql_query($sql) or die(mysql_error());
}
?>
<form method="POST" action="textarea.php">
<textarea name="txtDesc" row = "50" cols = "50" id="txtDesc" wrap="hard"></textarea>
<input type="submit" value="submit" name="submit">
</form>
Not sure what is the issue, some extra characters in the text area? I have printed the values and I don't see any extra characters that might be causing the problem. I keep getting the following error:
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 'description) VALUES('this a real escape string test')' at line 1
Thanks for the help in advance.