如何修复Parse错误:语法错误,意外'$ query'(T_VARIABLE)

时间:2016-06-12 12:39:02

标签: php mysql

<?php
include ("checklogin.php")


    $query = "select * from student";


    if($query_run =mysql_query($query))
    {
        echo "<table border='1' align= 'center'
            <tr>
                <th colspan= '11'> Student Lists</th>
            </tr>
            <tr>
                <th> ID </th>
                <th> Username </th>
                <th> Name </th>
                <th> Address </th>
                <th> Contact Number </th>
                <th> Identity Card </th>
                <th> License Number </th>
                <th> Email </th>
                <th> Gender </th>
                <th> Update </th>
                <th> Delete </th>

            </tr>";

        while($fetch= mysql_fetch_array($query_run))
        {
            echo"<tr>
                    <td>".$fetch['id']."</td>
                    <td>".$fetch['username']."</td>
                    <td>".$fetch['name']."</td>
                    <td>".$fetch['address']."</td>
                    <td>".$fetch['cn']."</td>
                    <td>".$fetch['ic']."</td>
                    <td>".$fetch['ln']."</td>
                    <td>".$fetch['email']."</td>
                    <td>".$fetch['sex']."</td>
        <td><a href='updatestudent.php?id=$fetch[id]&
        username=$fetch[username]&
        name=$fetch[name]&
        address=$fetch[address]&
        cn=$fetch[cn]&
        ic=$fetch[ic]&
        ln=$fetch[ln]&
        email=$fetch[email]&
        sex=$fetch[sex]'>
                <input type ='button' name='update'
                value='update'></a></td>
                <td><a href='deletestudent.php?id=[id]'>
                <input type='button' name='delete'
                value='delete'</a></td>
            </tr>";
        }

    }
    else
    {
        echo "<center>";
        echo "invalid query";
        echo "</center>";
    }

&GT;

1 个答案:

答案 0 :(得分:0)

if($query_run =mysql_query($query))

错了。请改用:

if($query_run ==mysql_query($query))