我正在尝试使用以下代码将表单中的数据插入两个不同的表中:
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
if(! get_magic_quotes_gpc() )
{
$date = addslashes ($_POST['date']);
}
else
{
$date = $_POST['date'];
}
$num_P1 = $_POST['num_P1'];
$num_P2 = $_POST['num_P2'];
$num_P3 = $_POST['num_P3'];
$num_P4 = $_POST['num_P4'];
$num_P5 = $_POST['num_P5'];
$num_B1 = $_POST['num_B1'];
$num_B2 = $_POST['num_B2'];
$jackpot = $_POST['jackpot'];
$jackpot2 = $_POST ['jackpot']*0.842799998;
$jp_code = $_POST['jp_code'];
$sql = "INSERT INTO euromillions ".
"(date, P1, P2, P3, P4, P5, B1, B2, jackpot, jp_code) ".
"VALUES('$date',$num_P1,$num_P2,$num_P3,$num_P4,$num_P5,$num_B1, $num_B2, $jackpot, $jp_code)".
"INSERT INTO euromillions_uk ".
"(date, P1, P2, P3, P4, P5, B1, B2, jackpot, jp_code) ".
"VALUES('$date',$num_P1,$num_P2,$num_P3,$num_P4,$num_P5,$num_B1, $num_B2, $jackpot2, $jp_code)";
mysql_select_db('lottotools');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
}
else
{
?>
我收到以下错误消息:
无法输入数据:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“INSERT INTO euromillions_uk (date, P1, P2, P3, P4, P5, B1, B2, jackpot, jp_code)" 附近使用正确的语法
有人可以建议我做错了什么。
谢谢!