2013-12-09 54 views
-3

我的客户端使用的是PHP 5.2.0版,我有一些完美的代码,但目前使用5.4.7。当我的代码在他们的服务器上运行时,我收到一个解析错误。我在网上搜索了一种替代方法来编写这段代码,但我找不到任何东西。如果任何人有任何提示,这将是一个很大的帮助。PHP版本 - 较低版本的难度编码

**$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>"; 

在上面的代码中,...-> fetch_row()[0];是带回错误的部分。 PHP 5.2.0不喜欢它。

+1

我很确定“PHP 5.2.0不喜欢它”。不是错误消息。始终分享确切的错误消息。 – PeeHaa

回答