Hi all, I'm new to this forum so be nice lol
I'm also very new to the whole MySQL and PHP thing, and its only taken me 3 days to connect to my webserver, so things are looking good.
Anyway, I'm finally in ... and I'm experimenting with INSERT. I got this code from a tutorial, added my details and kind of hoped it would work, but it doesn't.
The connection is fine, it's not that ...
The DB is called "bssql", the table is called "name" and has 2 columns, "firstname" and "lastname" CHAR(20).
I'm using the following form:
<form action="insert.php" method="post">
Firstname: <input type="text" name="firstname" />
Lastname: <input type="text" name="lastname" />
<input type="submit" />
and the following for "insert.php"
<?php
$con = mysql_connect("host","user","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("bssql", $con);$sql="INSERT INTO name (firstname, lastname,)
VALUES
('$_POST[firstname]','$_POST[lastname]',)";if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";mysql_close($con)
?>
and I get this responce ...
"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 ') VALUES ('Roger','Wilson',)' at line 1"
Roger Wilson is the name I was trying to insert into the table.
I hope this is enough information for some to help me ...
I'd really appreciate it if someone could point out where i'm going wrong please ...
Many Thanks, and Kind Regards
Gem