解析错误:语法错误,意外'}' 第19行/home/content/71/8956371/html/database/connect.php
代码对我来说很好看:看看connect.php
<?php
mysql_connect("timereliefusers.db.8956371.hostedresource.com", "*", "*") or die(mysql_error());
mysql_select_db("timereliefusers") or die (mysql_error());
$choice =(int) $_GET["choice"];
switch ($choice) {
case 1:
mysql_query("UPDATE poll1 set choice1 = choice1 + 1");
break;
case 2:
mysql_query("UPDATE poll1 set choice2 = choice2 + 1");
break;
case 3:
mysql_query("UPDATE poll3 set choice3 = choice3 + 1");
break;
}
}
?>
答案 0 :(得分:5)
嗯,你在第19行遇到了意外}。这意味着在第19行有一个不属于那里的}。
答案 1 :(得分:2)
为什么不这样做??
<?php
mysql_connect("timereliefusers.db.8956371.hostedresource.com", "*", "*") or die(mysql_error());
mysql_select_db("timereliefusers") or die (mysql_error());
$choice = (int) $_GET["choice"];
switch ($choice) {
case 1:
case 2:
mysql_query("UPDATE poll1 set choice" . $choice . " = choice" . $choice. " + 1");
break;
case 3:
mysql_query("UPDATE poll3 set choice" . $choice . " = choice" . $choice. " + 1");
break;
}
?>
答案 2 :(得分:1)
switch ($choice) {
case 1:
mysql_query("UPDATE poll1 set choice1 = choice1 + 1");
break;
case 2:
mysql_query("UPDATE poll1 set choice2 = choice2 + 1");
break;
case 3:
mysql_query("UPDATE poll3 set choice3 = choice3 + 1");
break;
}
}
应该是
switch ($choice) {
case 1:
mysql_query("UPDATE poll1 set choice1 = choice1 + 1");
break;
case 2:
mysql_query("UPDATE poll1 set choice2 = choice2 + 1");
break;
case 3:
mysql_query("UPDATE poll3 set choice3 = choice3 + 1");
break;
}
// removed the last "}"
答案 3 :(得分:0)
第19行有一个额外的“}”。文件中没有匹配的“{”。第17行包含第7行上switch语句的结束“}”。