如何修复php中的语法错误,意外的T_IF错误? [英] How to fix syntax error, unexpected T_IF error in php?
问题描述
解析错误:语法错误,第27行的view.php中出现意外的T_IF
Parse error: syntax error, unexpected T_IF in view.php on line 27
我的代码中确实没有发现任何问题,为什么会发生这种情况,请提供帮助.我是PHP的初学者
I really dont see any problem in my code, why this is happening, please help. Im a beginner in PHP
我的LINE 21在哪里>> if(isset($ _ GET ['page'])&& is_numeric($ _ GET ['page']))
Where my LINE 21 is >> if(isset($_GET['page']) && is_numeric($_GET['page']))
if ($result = $mysqli->query("SELECT * FROM players ORDER BY id"))
{
if ($result->num_rows > 0)
{
$total_result = $result->num_rows;
$total_pages = ceil($total_result / $per_page)
if(isset($_GET['page']) && is_numeric($_GET['page']))
{
$show_page = $_GET['page'];
if ($show_page > 0 && $show_page <= $total_pages)
{
$start = ($show_page - 1) * $per_page;
$end = $start + $per_page;
}
else
{
$start = 0;
$end = $per_page;
}
}
else
{
$start = 0;
$end = $per_page;
}
//display paginations
echo "<p> View pages: ";
for ($i=1; $i < $total_pages; $i++)
{
if (isset($_GET['page']) && $_GET['page'] == $i)
{
echo $i . " ";
}
else
{
echo "<a href='view-pag.php?$i'>" . $i . "</a> | ";
}
}
echo "</p>";
}
else
{
echo "No result to display.";
}
}
else
{
echo "Error: " . $mysqli->error;
}
推荐答案
PHP解析器错误需要一些习惯;如果它抱怨X行出现意外的情况",请首先查看X-1行.在这种情况下,它不会告诉您在上一行的末尾忘记了分号,而是会抱怨接下来的if
.
PHP parser errors take some getting used to; if it complains about an unexpected 'something' at line X, look at line X-1 first. In this case it will not tell you that you forgot a semi-colon at the end of the previous line , instead it will complain about the if
that comes next.
您会习惯的:)
这篇关于如何修复php中的语法错误,意外的T_IF错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!