PHP版本-较低版本的编码难度

PHP版本-较低版本的编码难度,php,mysql,Php,Mysql,我的客户机使用的是PHP版本5.2.0,我有一些代码可以很好地工作,但目前使用的是5.4.7。当我的代码在他们的服务器上运行时,我收到一个解析错误。我在网上搜索了另一种编写此代码的方法,但什么也找不到。如果有人有任何建议,那将是一个很大的帮助 **$count = mysqli_query($con, "SELECT COUNT(*) FROM menuitem")->fetch_row()[0];** //I want to make sure the previous and next

我的客户机使用的是PHP版本5.2.0,我有一些代码可以很好地工作,但目前使用的是5.4.7。当我的代码在他们的服务器上运行时,我收到一个解析错误。我在网上搜索了另一种编写此代码的方法,但什么也找不到。如果有人有任何建议,那将是一个很大的帮助

**$count = mysqli_query($con, "SELECT COUNT(*) FROM menuitem")->fetch_row()[0];** //I want to make sure the previous and next button are only displayed exactly to the number of items 
                                                                                  //in my database. I have to count those items, and turn that mysqli_query object into data. fetch_row[0] stores them
                                                                                  //in an array, starting at 0, turning it into an integer I can use to count below.
    $prev = $start - 3;
    if ($prev >= 0) {
        echo '<td><a href="?start=' . $prev . '">Previous Items</a></td>';// Set your $start - 3 since our offset is 3, and pass that to a variable.
    }                                                                     //if $start - 3 is still greater than 0, then display the previous button. Logically, that is page 2.

    $next = $start + 3;
    if ($next < $count) {
        echo '<td><a href="?start=' . $next . '">Next Items</a></td>';// Since i used fetch_row[0] I now know how many rows I have. If $start + 3 is less than the $count query
    }                                                                 // than you will have a next button. If that number exceeds the number of rows I have, then no next button.

echo "</tr>";    
echo "</table>";
**$count=mysqli\u查询($con,“从菜单项中选择count(*))->fetch\u row()[0];**//我想确保“上一步”和“下一步”按钮仅与项目数精确匹配
//在我的数据库里。我必须计算这些项目,并将mysqli_查询对象转换为数据。fetch_行[0]存储它们
//在一个数组中,从0开始,将其转换为一个整数,我可以用它在下面计数。
$prev=$start-3;
如果($prev>=0){
echo“”;//设置$start-3,因为偏移量是3,并将其传递给变量。
}//如果$start-3仍然大于0,则显示上一个按钮。从逻辑上讲,这就是第2页。
$next=$start+3;
如果($next<$count){
echo“”;//自从我使用fetch_行[0]以来,我现在知道我有多少行。如果$start+3小于$count查询
}//然后您将有一个“下一步”按钮。如果该数字超过我拥有的行数,则没有“下一步”按钮。
回声“;
回声“;
在上面的代码中,…->fetch_row()[0];是返回错误的部分。PHP5.2.0不喜欢它。

在PHP5.4之前,您需要。简单地做:

$count = mysqli_query(...)->fetch_row();
$count = $count[0];
我相当肯定“PHP5.2.0不喜欢它。”不是错误消息。始终共享准确的错误消息。