I'm trying to use the following script to update a test database and it errors out. I can't seem to figure it out.
<?
$db = mysql_connect("localhost","root");
mysql_select_db (recipes);
$result = mysql_query ("INSERT INTO (name,ingredients,directions,yield,category)
VALUES ('$name' , '$ingredients' , '$directions' , '$yield' , '$category' ) ");
if(!$result)
{
echo "<b>Something not added:</b> <br>", mysql_error();
exit;
}
if($result)
{
mysql_close($db);
print "Something added sucessfully!";
}
?>
Here's the error...
Something not added:
You have an error in your SQL syntax near '(name,ingredients,directions,yield,category) VALUES ('' , '' ,' at line 1
Thank you
Newbie PHP/Mysql question
Moderator: General Moderators
You're missing a table name in your insert statement:
Code: Select all
$result = mysql_query ("INSERT INTO tablename(name,ingredients,directions,yield,category)
VALUES ('$name' , '$ingredients' , '$directions' , '$yield' , '$category' ) ");I seem to remember that I was a newbie once too. Don't sweat it.TomEd wrote:DUHI feel stoopit!
Thank you very much.
I looked at that line a million times and still couldn't see that. I feel kinda foolish, but after all I can claim "newbie" as my defense.(I hope)
Thanks again
Tom
One hint though. Give us the error messages as it will help us figure out what's going on.
Cheers,
BDKR