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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?