【问题标题】:PHP throws Parse error: syntax error, unexpected ' " ' [duplicate]PHP抛出解析错误:语法错误,意外'“' [重复]
【发布时间】:2018-06-29 13:31:45
【问题描述】:

我创建了一个系统,员工可以在其中查看他们申请的休假状态。我正在尝试根据用户是否登录来显示已申请的休假状态。

这是一个例子:

所以登录的用户是 John Doe,但由于某种原因,我可以看到其他用户提出的其他申请。我只希望 John Doe 看到他自己的应用的叶子。

这是我想出的代码:

<div class="container">
    <div class="page-header">
        <h3>My Leaves</h3>
        <div class="table-responsive">
            <table class="table">
                <tr>
                    <th>Employee Name</th>
                    <th>Phone</th>
                    <th>Email</th>
                    <th>From</th>
                    <th>To</th>
                    <th>Reason</th>
                    <th>Status</th>
                </tr>
                <?php
                include ('database.php');
                $result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.username = $_SESSION["VALID_USER_ID"]");
                $result ->execute();
                for ($count=0; $row_message = $result ->fetch(); $count++){ ?>
                <tr>
                    <td><?php echo $row_message['full_name']; ?></td>
                    <td><?php echo $row_message['phone']; ?></td>
                    <td><?php echo $row_message['email']; ?></td>
                    <td><?php echo $row_message['fromdate']; ?></td>
                    <td><?php echo $row_message['todate']; ?></td>
                    <td><?php echo $row_message['reason']; ?></td>
                    <td><?php echo $row_message['status']; ?></td>
                </tr>
                <?php } ?>
            </table>
            <a href="home"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button></a>
        </div>
    </div>
</div>

不幸的是,我收到了Parse error: syntax error, unexpected '"'

在下面一行:

$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.username = $_SESSION["VALID_USER_ID"]");

我不确定它是什么。

这是我的表架构:

【问题讨论】:

  • 只要把结尾改成employee.username = " . $_SESSION["VALID_USER_ID"]);

标签: php html mysql database phpmyadmin


【解决方案1】:

您将如下更改查询并尝试。

$result = $database->prepare ("SELECT leaves.* FROM leaves INNER JOIN employee ON employee.id = leaves.user_id WHERE employee ON employee.id = leaves.user_id WHERE employee.id = ".$_SESSION["VALID_USER_ID"]);

【讨论】:

  • 非常感谢。所有申请的休假细节都消失了,但我想这是一个不同的问题。再次感谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-27
  • 2018-06-28
  • 2016-02-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多