jdubwelch Posted December 5, 2006 Share Posted December 5, 2006 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 https://forums.phpfreaks.com/topic/29485-error-trying-to-insert-data/ Share on other sites More sharing options...
jdubwelch Posted December 5, 2006 Author Share Posted December 5, 2006 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 https://forums.phpfreaks.com/topic/29485-error-trying-to-insert-data/#findComment-135325 Share on other sites More sharing options...
fenway Posted December 6, 2006 Share Posted December 6, 2006 FYI, you shouldn't pass in NULL for an auto-increment... just drop the column from the list.. Link to comment https://forums.phpfreaks.com/topic/29485-error-trying-to-insert-data/#findComment-135966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.