I'm a newbie to PHP, but this is a coding problem, so I don't know if I should post here or not, but I seem to have a problem inserting a textarea value into my table, I can't seem to figure out why it doesn't work. Here is my script
$ministry = $POST["textfield"];
$desc = $POST["textarea"];
$base = $_COOKIE["base"];
$sql = "SELECT * FROM ministry WHERE base = '$base' AND ministry = '$ministry'";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
IF (mysql_num_rows(mysql_query($sql))) {echo "Sorry, '$ministry' already exists for '$base'. Please enter a different ministry or change to a different base."; }else {
$add = "INSERT INTO ministry (base, ministry) VALUES ('$base', '$ministry')";
$add2 = "INSERT INTO ministry (desc) VALUES ('$desc')";
mysql_query($add) or die(mysql_error());
mysql_query($add2) or die(mysql_error());
$minnew = mysql_fetch_assoc(mysql_query($sql));
echo "Base: $minnew[base] Ministry: $minnew[ministry]";}
?>
$add used to be one query but I seperated it to try to find the problem. When it runs, the second query fails and I get the following error message:
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 'desc) VALUES ('Feed')' at line 1
Thanks in advance for your help