Hi guys,
Ive been experimenting with the INSERT INTO command and am having a few problems with my code. The SQL statement looks good and if filled with all the correct details but every time i think i know what the problem is i come to a dead end again. The code is as follows
<?php
$con = mysql_connect("local host","user","pass");
if (!$con)
{
die('Could not connect' . mysql_error());
}
mysql_select_db("my_db", $con);
$SQL="INSERT INTO GIFT (`title`, `desc`, `gender`, `event`, `age`, `imglnk`, `productlnk`, `price`)
VALUES
('$_POST[title]', '$_POST[desc]', '$_POST[gender]', '$_POST[occasion]','$_POST[age]', '$_POST[imagelink]', '$_POST[productlink]', '$_POST[price]')"
if (!mysql_query($SQL,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
The error is syntax error, unexpected T_IF on line 17 which is where i run the mysql query "if (!mysql_query($SQL,$con))"
thanks again