Code: Select all
$sql="INSERT INTO series (sname, sseason, syear, sseries)
There is something wrong here. You have not completed the insert statement. It may look something like this:
Code: Select all
$sql = "INSERT INTO series (sname, sseason, syear, sseries) VALUES ('$sname', '$sseason', '$syear', '$sseries')";
Or whatever the variables are you are wanting to add to the database. The first set of ( ) is only saying what columns you will be inserting values into. You don't have to insert data into each column. If you don't insert data into some columns, they will get a NULL value. If you are inserting data into all columns, you can change your query to this:
Code: Select all
$sql = "INSERT INTO series VALUES ('$sname', '$sseason', '$syear', '$sseries')";
However, you can only do it this way if sname, sseason, syear, sseries are the only columns in the `series` table.
As for the issue of getting an error that you can't have an identical entry, that would be right. MySQL, and most other relational databases don't allow identical entries. The fix for this, if you need identical entries is to create an "id" column. Make it the primary key, and set it to auto-increment. Then on your insert queries, you will have to use the first form I showed above, because you won't ever be setting the "id" column directly. MySQL will automatically give it a number, and will add 1 to the next number for every new entry. That way you will never have 2 identical id columns, and no entries will ever be identical.
Let me know if you need more help
EDIT: Oh, I actually see you were using the second form when I looked at the whole script. I am not sure MySQL will like having a linebreak in the middle of a query. Put it all on one line. Also, you may need to get those $_POST[] values into regular variables before putting them into the SQL query string. PHP sometimes does not like associative array references (like $_POST['something']) inside of double-quote strings. I have been told the reason why this is before, but I forgot. So if you ever have a problem when you have array references like that built into a string, try either putting them into regular strings first, or concatenate the string, like this:
Code: Select all
$a = "This is ".$_POST['something']." and this is ".$_POST['somethingElse']."!!";
See what I mean. Being able to put variable references directly into double-quote strings is just a convenience. If it gives you trouble, there are other ways to do it.