Jump to content

INSERT Query


redwall_hp

Recommended Posts

$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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...