任何机构都可以告诉为什么这个剧本正在提供
<?php
session_start();
$con = mysqli_connect("localhost", "root", "", "QSTNS");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: ".mysqli_connect_error();
$res = mysqli_query($con, 'SELECT COUNT(*) FROM qstns');
$row = mysqli_fetch_array($res);
$scoreis = 0;
for ($i = 0; $i < $row[0]; $i++) {
$scoreis = $scoreis + $_SESSION['scr'][$i];
}
echo $scoreis;
mysqli_close($con);
?>
错误是: 解析错误:语法错误,第32行C:\ wamp \ www \ quiiz_portal \ scoreis.php中的意外文件结尾
答案 0 :(得分:2)
您在}
尝试此操作后忘记关闭if (mysqli_connect_errno()) {
:
$con = mysqli_connect("localhost", "root", "", "QSTNS");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: ".mysqli_connect_error();
}
$res = mysqli_query($con, 'SELECT COUNT(*) FROM qstns');
$row = mysqli_fetch_array($res);
$scoreis = 0;
for ($i = 0; $i < $row[0]; $i++) {
$scoreis = $scoreis + $_SESSION['scr'][$i];
}
echo $scoreis;
mysqli_close($con);
答案 1 :(得分:0)
if (mysqli_connect_errno()) {
没有匹配的大括号,你需要说明if结束的位置