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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.