redwall_hp Posted September 29, 2006 Share Posted September 29, 2006 $query = mysql_query("INSERT INTO mpoll_results (question,numberofoptions,opt1,opt2,opt3,opt4,opt5,opt6,opt7,opt8,opt9,opt10,count1,count2,count3,count4,count5,count6,count7,count8,count9,count10,totalvotes) VALUES($question,$numberofoptions,$opt1,$opt2,$opt3,$opt4,$opt5,$opt6,$opt7,$opt8,$opt9,$opt10,$count1,$count2,$count3,$count4,$count5,$count6,$count7,$count8,$count9,$count10,$totalvotes)") or die(mysql_error()); I'm making an AJAX poll script, but I ran into a brick wall here, sort of. I'm using some quick values I came up with so the script has something to work with. Unfortunately, I get the followng MYSQL error instead of the script continueing. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Question,10,Option 1,Option 2,Option 3,Option 4,Option 5,Option Anyone know what the problem is? Link to comment Share on other sites More sharing options...
jesh Posted September 29, 2006 Share Posted September 29, 2006 Perhaps it has something to do with that "& #40;" that is in your query. Shouldn't that be a "("? Link to comment Share on other sites More sharing options...
redwall_hp Posted September 29, 2006 Author Share Posted September 29, 2006 Nope. It's not like that in the source code. Just here on the forum. Don't know why... Link to comment Share on other sites More sharing options...
Ruud Hermans Posted September 30, 2006 Share Posted September 30, 2006 If the server is running on your localhost try using something like: C:\>mysql -h localhost -u user -p Then when asked for your password insert it.connect to the right databse with the following command: USE (databasename); Then try to add the information to your database simular to the following: INSERT INTO (table) (last_name, first_name) VALUES('Stein','Waldo'); Replace (table) with your table the () also need to go.Ore use: LOAD DATA LOCAL INFILE "file.txt" INTO TABLE (table); Ruud Hermans Link to comment Share on other sites More sharing options...
redwall_hp Posted October 1, 2006 Author Share Posted October 1, 2006 ErrorSQL query:INSERT INTO mpoll_results( last_name, first_name )VALUES ('Stein', 'Waldo')MySQL said: Documentation#1054 - Unknown column 'last_name' in 'field list' Link to comment Share on other sites More sharing options...
Ruud Hermans Posted October 1, 2006 Share Posted October 1, 2006 I ment it should look something like this: INSERT INTO mpoll_results (question, numberofoptions, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8, opt9, opt10, count1, count2, count3, count4, count5, count6, count7, count8, count9, count10, totalvotes) VALUES('question','numberofoptions','opt1','opt2','opt3','opt4','opt5','opt6','opt7','opt8','opt9','opt10','count1','count2','count3','count4','count5','count6','count7','count8','count9','count10','totalvotes'); See if I got the table name right couse I couldn't figure out what "& #40" ment.Ruud Hermans Link to comment Share on other sites More sharing options...
redwall_hp Posted October 1, 2006 Author Share Posted October 1, 2006 I just got it working. There weren't any single-quotes around the values. That was kind of dumb. Thanks for the help, anyway.P.S. You can view the poll at http://siteofrequirement.com/mpoll/voting3/createpoll.phpI plan to clean up the code and make it available as donate-ware eventually on webmaster-source.com. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now