Jump to content

simple insert command gone bad (please help!)


Jutboy420

Recommended Posts

I'm trying to keep track of all the movies a person votes for via their IP address.

This script inserts the users ip address and the fact they voted for movie 1 by changing the column 1 (signifying movie one) to the number 1 (default = 0 = not voted)...I really want to make the column 1 a variable and really don't want to change using an int as as my column.

$sqlr = "INSERT INTO voters (ip,1) VALUES ('$ip',1)";
mysql_query($sqlr) or die(mysql_error());

all values confirmed....db structure checked.

Please help!! Thank you so much - Justin
You're not allowed to name a column with a number. It must start with an alphabet character. Why call it "1"? Why not 'voted' or something like that?

Also your database structure sounds ill-thought out. You have a table for every movie? So every time you add a movie, you add a table to the database? That's not good design.

Why not 3 tables:
movies (id, title, description)
users (id, ipaddress)
votes (userid, movieid)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.