三个php变量中的一个没有被正确看到

时间:2014-12-09 23:54:52

标签: php mysql

我有这个网址:

http://nbastats.org/np2pp2.php?firstname=abc&lastname=def&firstseason=1900

这些是我的PHP变量:

$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
$firstseason = $_GET['firstseason'];

然后是我的SQL:

$sql2="INSERT INTO playerRegSeason 
       (playerID, year, teamID, gp, minutes, pts, oreb, dreb, reb, 
        asts, stl, blk, turnover, pf, fga, fgm, fta, ftm, tpa, tpm)

       SELECT playerID, $year, '$team', $gp, $minutes, $pts, $oreb, 
         $dreb, $reb, $asts, $stl, $blk, $turnover, $pf, $fga, $fgm, 
         $fta, $ftm, $tpa, $tpm FROM players WHERE firstname='".$firstname."' 
       AND lastname='".$lastname."' AND firstseason='".$firstseason."'";

最后收到错误消息:

Error: 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 players WHERE 
firstname='abc' AND lastname='def' AND firstseason=' at line 7

我知道$ firstseason正在被拉,因为我能够回应它,但由于某种原因它在SQL语句中不起作用,即使其他两个是。我假设它与其他是字符串的数字有关。我说的唯一原因是因为这是我能看到的唯一不同的东西。非常感谢任何帮助,谢谢。

编辑:

如果我回复我的SQL它的内容如下:(所以肯定会得到这个数字,但我仍然有上面的错误。

INSERT INTO playerRegSeason (playerID, year, teamID, gp, minutes, pts, oreb, dreb, reb, 
asts, stl, blk, turnover, pf, fga, fgm, fta, ftm, tpa, tpm) SELECT playerID, 1900, '', 
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, , FROM players WHERE firstname='abc' 
AND lastname='def' AND firstseason='1900'

和我要执行的代码:

if (!mysqli_query($con,$sql2)) {
        die('Error: ' . mysqli_error($con));
    }

    mysqli_close($con);

0 个答案:

没有答案