I have the following code which puts data into a mysql database:
$sql3 = "INSERT INTO $tableName (topic, title, date) VALUES ('$topic','$title','$today')";
mysql_query($sql3);
It works perfectly.
However, when I use the code within a function, it doesn't work. The parameters passed into the function are used elsewhere in the code and should not affect the operation of the code above.
When I add:
if(mysql_errno()){
echo "MySQL error ".mysql_errno().": "
.mysql_error()."\n<br>When executing <br>\n$query\n<br>"; }
I get the error:
MySQL error 1064: 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 '(topic, title, date) VALUES ('weather','It looks like Autumn is he' at line 1 When executing
I can't figure out why there is an SQL syntax error when the code is used in a function but not when it is on its own.
Thanks for you help in advance.