Jutboy420 Posted February 26, 2006 Share Posted February 26, 2006 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 https://forums.phpfreaks.com/topic/3610-simple-insert-command-gone-bad-please-help/ Share on other sites More sharing options...
AndyB Posted February 26, 2006 Share Posted February 26, 2006 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. Link to comment https://forums.phpfreaks.com/topic/3610-simple-insert-command-gone-bad-please-help/#findComment-12509 Share on other sites More sharing options...
wickning1 Posted February 26, 2006 Share Posted February 26, 2006 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 https://forums.phpfreaks.com/topic/3610-simple-insert-command-gone-bad-please-help/#findComment-12541 Share on other sites More sharing options...
Jutboy420 Posted February 27, 2006 Author Share Posted February 27, 2006 I did it AndyB way and it worked fine....your write to columns as numbers...shame shame....Thanks a heap - Jutboy Link to comment https://forums.phpfreaks.com/topic/3610-simple-insert-command-gone-bad-please-help/#findComment-12843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.