Jump to content

Error Trying to Insert Data


jdubwelch

Recommended Posts

i can do it fine in phpMyAdmin.  I basically inserted 1 row of info in phpMyAdmin and copied the query as my guide.

this is the query:

[code]$query = "INSERT INTO team_stats (team_stat_id, game_id, year_id, home_away_id, team,
mascot, abbr, rank, record, score, q1, q2, q3, q4, ot, firstdowns, totoff, rush_att_yds,
pass_att_comp, passyds, sacked, third, redzone, to, fum, int, pryds, kryds, totyds, top)

VALUES (NULL, {$_POST[gm]}, 1, 2, {$_POST[away]}, {$_POST[away_mascot]}, {$_POST[away_abbr]}, {$_POST[away_rank]}, {$_POST[record]}, {$_POST[score]},
{$_POST[q1]}, {$_POST[q2]}, {$_POST[q3]}, {$_POST[q4]}, {$_POST[ot]},
{$_POST[firstdowns]}, {$_POST[totoff]}, {$_POST[rush_att_yds]}, {$_POST[pass_att_comp]},
{$_POST[passyds]}, {$_POST[sacked]}, {$_POST[third]}, {$_POST[redzone]}, {$_POST[to]},
{$_POST[fum]}, {$_POST[int]}, {$_POST[pryds]}, {$_POST[kryds]}, {$_POST[totyds]},
{$_POST[top]})";[/code]

i echo the query in the page and this is what it looks like:
[code]INSERT INTO team_stats (team_stat_id, game_id, year_id, home_away_id, team,
mascot, abbr, rank, record, score, q1, q2, q3, q4, ot, firstdowns, totoff, rush_att_yds,
pass_att_comp, passyds, sacked, third, redzone, to, fum, int, pryds, kryds, totyds, top)
VALUES (NULL, 3, 1, 2, Tennessee, Volunteers, TENN, 17, 2-2, 21, 7, 7, 7, 0, -, 9, 256,
14-16, 16-24-3, 240, 5, 3-8, 3-3-0, 3, 4-2, 1, 0, 109, 365, 9:22)[/code]

this is the error the page prints out:
[code]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 'to, fum, int, pryds, kryds,
totyds, top) VALUES (NULL, 3, 1, 2, Tennessee, Volun' at line 1[/code]

what's wrong with it?
Link to comment
Share on other sites

i played with it more and got it.  nm

[code] $query = "INSERT INTO `team_stats` (`team_stat_id`, `game_id`, `year_id`,
`home_away_id`, `team`, `mascot`, `abbr`, `rank`, `record`, `score`, `q1`, `q2`,
`q3`, `q4`, `ot`, `firstdowns`, `totoff`, `rush_att_yds`, `pass_att_comp`, `passyds`,
`sacked`, `third`, `redzone`, `to`, `fum`, `int`, `pryds`, `kryds`, `totyds`, `top`)

VALUES (NULL, '{$_POST[gm]}', '1', '2', '{$_POST[away]}', '{$_POST[away_mascot]}',
'{$_POST[away_abbr]}', '{$_POST[away_rank]}', '{$_POST[record]}', '{$_POST[score]}',
'{$_POST[q1]}', '{$_POST[q2]}', '{$_POST[q3]}', '{$_POST[q4]}', '{$_POST[ot]}',
'{$_POST[firstdowns]}', '{$_POST[totoff]}', '{$_POST[rush_att_yds]}',
'{$_POST[pass_att_comp]}', '{$_POST[passyds]}', '{$_POST[sacked]}',
'{$_POST[third]}', '{$_POST[redzone]}', '{$_POST[to]}', '{$_POST[fum]}', '{$_POST[int]}',
'{$_POST[pryds]}', '{$_POST[kryds]}', '{$_POST[totyds]}', '{$_POST[top]}'),

(NULL, '{$_POST[gm]}', '1', '1', '{$_POST[home]}', '{$_POST[home_mascot]}', '{$_POST[home_abbr]}', '{$_POST[home_rank]}', '{$_POST[record2]}', '{$_POST[score2]}',
'{$_POST[q12]}', '{$_POST[q22]}', '{$_POST[q32]}', '{$_POST[q42]}', '{$_POST[ot2]}',
'{$_POST[firstdowns2]}', '{$_POST[totoff2]}', '{$_POST[rush_att_yds2]}',
'{$_POST[pass_att_comp2]}', '{$_POST[passyds2]}', '{$_POST[sacked2]}',
'{$_POST[third2]}', '{$_POST[redzone2]}', '{$_POST[to2]}', '{$_POST[fum2]}',
'{$_POST[int2]}', '{$_POST[pryds2]}', '{$_POST[kryds2]}', '{$_POST[totyds2]}',
'{$_POST[top2]}');";
[/code]
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.