dongshang1529 2013-12-19 07:26
浏览 106
已采纳

解析错误:语法错误,意外的T_IS_GREATER_OR_EQUAL

over the past few weeks ive been learning php, its been quite a daunting task but stack overflow has helped me alot. I am currently having issues with a parse error,

<?php
include('config.php');
function html($html)
{
    return htmlentities($html, ENT_QUOTES, 'utf-8');
}
?>
<html xmlns="http://www.w3.org/1999/xhtml"/>
<head>
    <meta http-equiv="content-type" content="text/html"/>
    <link href="<?php echo $design ?>/style.css" rel="stylesheet" title="Style">
    <title><?php echo $title ?></title>
</head>
<body>
<html>
<div class="header">
    <a href="<?php echo $root ?>" img src="<?php echo $design ?>/images/<?php echo $logo ?>" alt="home"/>
</div>
<table class="home" cellpadding="0" cellspacing="0">
    <tr>
        <th class="rank_th">Ranking</th>
        <th class="site_th">Site</th>
        <th class="votes_th">Votes</th>
    </tr>
    <?php
    //we get #sites
    $req1 = mysqli_fetch_array(mysqli_query('SELECT COUNT(id) as # FROM Sites WHERE status="ok"'));
    //we get current top
    IF (isset($_GET['Page'])) {
        $page = intval($_GET['page']);
    } else {
        $page = 1;
    }
    //calculate #pages & display page links
    $nbpage = ceil($req1['nb'] / $nbpage);
    if ($page < 1 or $page > $nbpage);
    { >= 'Pages: ';
        if ($page > 1) {
            $pages_site .= '<a href="?page='. ($page - 1) .'">'last </a> ';
    }
    for ($i=1;$i<=$nbpage;$i++)
    {
    if ($i==$page){
            $pages_site .=<strong> .$i. </strong>';
    }
    }
    if ($page < $page<$nbpage){
        $pages_site .= '<a href="?page=' . ($page + 1) .'">next</a>')''
    }
    ?>
    <tr>
        <td colspan="3" class="pages"><?php ECHO $pages_site; ?></td>
    </tr>
    <div class="new">Please <a href="Register.php">register</a> or <a href="login.php">to add your website.</a> </div>
    <?php
    //calculate order
    $first_site = ($page-1)*$nbpage;
    $last_site = $first_site +$nbpage;
    $i=$first_site ;
    //display sites
    $req2 = mysqli_query('select id, url, name, description, banner, votes FROM sites where status="ok" order .by votes desc limit ' .$first_site . ',' .$last_site .);
    while($dnn2 = mysqli_fetch_array($req2))
    {
        $i++;
    }
    ?>
    <tr>
        <td class="ranking"><?php echo $i; ?> </td>
        <td class="site"><a href="http://<?php echo html($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo html($dnn2['name']); ?></a><br />
            <?php echo html($dnn2['description']); ?><br />
            <a href="http://<?php echo html($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo html($dnn2['url']); ?></a>
            <div style="text-align:center;"<a href="http://<?php echo html($dnn2['url']?>"><img src="<?php echo html($dnn2['banner'],?>" alt="<?php echo html($dnn2['name']); ?>" style="max-width:500px;max-height:200px;" /></a></div></td>
        <td class="votes"><?php echo html($dnn2['votes']); ?> <br /><a href="vote.php<?php echo ($dnn2['id']); ?>">vote</a></td>
    </tr>
    <?php
    }
    //display page # again
    ?>
    <tr>
        <td colspan="3" class="pages"> <?php echo $pages_site; ?></td>
    </tr>
</table>
<div class="footer">
    <?php echo $footer ?>
</div>
</body>
</html>

/**
* Created by PhpStorm.
* User: weller
* Date: 19/12/13
* Time: 11:41 AM
*/

is the index.php page.

<?php
//change to your details.
$host = 'localhost';
$user = 'username';
$pass = 'password';
$dbname = 'database';
//connects here(dont change)
$db = mysqli_connect($host, $user, $pass, $dbname);
//webmaster email
$mail1 = 'webmaster@site.com';
//site root url
$root = 'www.site.com/';
//homepage filename
$index = 'index.php';
//pages per index
$nbpages = '10';
//css name
$design = 'default';
//site title
$title = 'LOLOLOL';
//Footer msg
$footer = 'LOLOL';
?>


/**
* Created with PhpStorm.
* User: weller
* Date: 19/12/13
* Time: 11:31 AM
*/

is the config.php

and my parse error is: Parse error: syntax error, unexpected T_IS_GREATER_OR_EQUAL in /home3/crazycr1/public_html/index.php on line 37

every parse error ive had sofar ive been able to solve with google but this one has had me stumped for an hour now. i have tried moving the >= around and i did try a few other ways of doing it but i keep getting the same issue. any help at all is welcome && feel free to check for easier or more secure ways of doing things. THANKS :D weller.

  • 写回答

4条回答 默认 最新

  • dongse5528 2013-12-19 07:34
    关注

    here is the correct from. Thanks

    /**
     * Created by PhpStorm.
     * User: weller
     * Date: 19/12/13
     * Time: 11:41 AM
     */
    include('config.php');
    function html($html)
    {
        return htmlentities($html, ENT_QUOTES, 'utf-8');
    }
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml"/>
    <head>
        <meta http-equiv="content-type" content="text/html"/>
        <link href="<?php echo $design ?>/style.css" rel="stylesheet" title="Style">
        <title><?php echo $title ?></title>
    </head>
    <body>
    <html>
    <div class="header">
        <a href="<?php echo $root ?>" img src="<?php echo $design ?>/images/<?php echo $logo ?>" alt="home"/>
    </div>
    <table class="home" cellpadding="0" cellspacing="0">
        <tr>
            <th class="rank_th">Ranking</th>
            <th class="site_th">Site</th>
            <th class="votes_th">Votes</th>
        </tr>
        <?php
        //we get #sites
        $query = "SELECT COUNT(id) as # FROM Sites WHERE status=`ok`";
        $req1 = mysqli_fetch_array(mysqli_query($query, $db));
        //we get current top
        IF (isset($_GET['Page'])) {
            $page = intval($_GET['page']);
        } else {
            $page = 1;
        }
        //calculate #pages & display page links
        $nbpage = ceil($req1['nb'] / $nbpage);
        if ($page < 1 or $page > $nbpage);
        {
            $pages_site = 'Pages: ';
            if ($page > 1) {
                $pages_site .= '<a href="?page='. ($page - 1) .'">last</a>';
        }
        for ($i=1;$i<=$nbpage;$i++)
        {
        if ($i==$page){
                $pages_site .='<strong> .$i. </strong>';
        }
        }
        if ($page < $nbpage){
            $pages_site .= '<a href="?page=' . ($page + 1) .'">next</a>';
        }
        ?>
        <tr>
            <td colspan="3" class="pages"><?php ECHO $pages_site; ?></td>
        </tr>
        <div class="new">Please <a href="Register.php">register</a> or <a href="login.php">to add your website.</a> </div>
        <?php
        //calculate order
        $first_site = ($page-1)*$nbpage;
        $last_site = $first_site +$nbpage;
        $i=$first_site ;
        //display sites
        $query1 = 'select id, url, name, description, banner, votes FROM sites where status="ok" order .by votes desc limit ' .$first_site . ',' .$last_site;
        $req2 = mysqli_query($query1, $db);
        while($dnn2 = mysqli_fetch_array($req2))
        {
            $i++;
        }
        ?>
        <tr>
            <td class="ranking"><?php echo $i; ?> </td>
            <td class="site"><a href="http://<?php echo html($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo html($dnn2['name']); ?></a><br />
                <?php echo html($dnn2['description']); ?><br />
                <a href="http://<?php echo html($dnn2['url']); ?>" style="color:#0000ff;text-decoration:underline;font-weight:bold;"><?php echo html($dnn2['url']); ?></a>
                <div style="text-align:center;"<a href="http://<?php echo html($dnn2['url']);?>"><img src="<?php echo html($dnn2['banner']);?>" alt="<?php echo html($dnn2['name']); ?>" style="max-width:500px;max-height:200px;" /></a></div></td>
            <td class="votes"><?php echo html($dnn2['votes']); ?> <br /><a href="vote.php<?php echo ($dnn2['id']); ?>">vote</a></td>
        </tr>
        <?php
        }
        //display page # again
        ?>
        <tr>
            <td colspan="3" class="pages"> <?php echo $pages_site; ?></td>
        </tr>
    </table>
    <div class="footer">
        <?php echo $footer ?>
    </div>
    </body>
    </html>
    

    corrections:

    /**
     * Created by PhpStorm.
     * User: weller
     * Date: 19/12/13
     * Time: 11:41 AM
     */
    

    this needed to in a php tag.

    "> bracket expected.

    'select id, url, name, description, banner, votes FROM sites where status="ok" order .by votes desc limit ' .$first_site . ',' .$last_site . extra dot put and also db connect link wasn't in the param.

    if ($page < $page

    quotes are not put correctly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用