这里是我的代码有任何语法错误,请指导我
$degree = $_POST['edu'];
$board = $_POST['bu'];
$result = $_POST['rdd'];
$marks = $_POST['tm'];
$maketemp = "CREATE TEMPORARY TABLE temp_table_1 ( `degree` varchar(100),`board` varchar(100),`resultd` varchar(100), `marks` varchar(100),)";
mysql_query($maketemp);
$insertemp = "INSERT INTO temp_table_1 (degree, board, resultd, marks ) VALUES ('$degree', '$board', '$resultd', '$marks',) ";
mysql_query($insertemp);
$show = mysql_query("SELECT * FROM temp_table_1");
if($show)
{
while($row = mysql_fetch_assoc($show)){
echo $row['degree'];
}
答案 0 :(得分:1)
两个查询中的语法错误,只需将此查询替换为此...
$maketemp = "CREATE TEMPORARY TABLE temp_table_1 ( `degree` varchar(100),`board`
varchar(100),`resultd` varchar(100), `marks` varchar(100))"; // removed last comma
mysql_query($maketemp);
$insertemp = "INSERT INTO temp_table_1 (degree, board, resultd, marks ) VALUES ('$degree',
'$board', '$resultd', '$marks') "; // removed last comma
答案 1 :(得分:0)
查询中存在一些错误。 从create table中的查询末尾删除TEMPORARY和','。
将其更改为此
CREATE TABLE temp_table_1 ( `degree` varchar(100),`board` varchar(100),`resultd` varchar(100), `marks` varchar(100))
INSERT INTO temp_table_1 (degree, board, resultd, marks ) VALUES ('".$degree."','".$board."','".$resultd."', "'.$marks."'")
答案 2 :(得分:0)
我发现4个错误:
Extra comma after`marks` varchar(100)
Extra comma after '$marks'
Missing 'd' on $result = $_POST['rdd'];
Missing end brace of the if statement
以下是工作版本。我建议使用
die( die(mysql_error() . "<br>Query: " . ...)
每个mysql_query()之后。它提供了很多帮助。
$degree = $_POST['edu'];
$board = $_POST['bu'];
$resultd = $_POST['rdd'];
$marks = $_POST['tm'];
$maketemp = "CREATE TEMPORARY TABLE temp_table_1 (
`degree` varchar(100),
`board` varchar(100),
`resultd` varchar(100),
`marks` varchar(100)
)";
mysql_query($maketemp) or die(mysql_error() . "<br>Query: " . $maketemp);
$insertemp = "INSERT INTO temp_table_1 (
degree, board, resultd, marks
) VALUES (
'$degree', '$board', '$resultd', '$marks'
) ";
mysql_query($insertemp) or die(mysql_error() . "<br>Query: " . $inserttemp);
$select_temp = "SELECT * FROM temp_table_1";
$show = mysql_query($select_temp) or die(mysql_error() . "<br>Query: " . $select_temp);
if($show) {
while($row = mysql_fetch_assoc($show)){
echo "<br>".$row['degree'];
echo "<br>".$row['board'];
echo "<br>".$row['resultd'];
echo "<br>".$row['marks'];
}
}
?>