The following query in sql_insertPlayerWeeklyPassingStats(21088, 2005, Array); failed:
INSERT INTO ind_gbgpassing (`id`, `year`, wk, cmp, att, yds, sack, td, `int`, `long`) SELECT id, `year`, 1, 21-cmp, 31-att, 311-yds, 1-sack, 3-td, 1-`int`, IF(`long`>65,`long`,65 FROM ind_passing WHERE id = 21088 AND `year` = 2005
MySQL said: 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 'FROM ind_passing WHERE id = 21088 AND `year` = 2005' at line 1
below is the code I use, do you guys understand why this is messing up. I am 99% sure it has to do with lines being produced like this
21-cmp, 31-att, 311-yds, 1-sack, 3-td, 1-`int`
Any help would sure be appreciated
Code: Select all
function sql_insertPlayerGbgPassingStats($id, $year, $table)
{
$db_table = MYSQL_PASSING;
$weeklydb_table = MYSQL_GBGPASSING;
$cmp = $table[2]; $att = $table[3]; $yds = $table[4]; $sack = $table[7]; $td = $table[8];
$int = $table[9]; $long = $table[10]; $wk = $_POST["wk"];
$query = "INSERT INTO $weeklydb_table "
."(`id`, `year`, wk, cmp, att, yds, sack, td, `int`, `long`) "
."SELECT id, `year`, $wk, $cmp-cmp, $att-att, $yds-yds, $sack-sack, $td-td, $int-`int`, IF(`long`>$long,`long`,$long "
."FROM $db_table "
."WHERE id = $id AND `year` = $year ";
$result = @mysql_query($query);
echo $query;
if ($result == false)
return errorPrint("The following query in sql_insertPlayerWeeklyPassingStats($id, $year, $table); failed: <p><tt>$query</tt></p>");
return true;
}