Jump to content

Archived

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

Jutboy420

simple insert command gone bad (please help!)

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

Share this post


Link to post
Share on other sites
Why not just have the two pieces of data represent an IP address and a movie number. If they haven't voted for movie x, then there won't be a record in the table with 'their' IP address and movie number x.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
I did it AndyB way and it worked fine....your write to columns as numbers...shame shame....

Thanks a heap - Jutboy

Share this post


Link to post
Share on other sites

×

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.