0

mysql语法有什么问题吗,我相信语法是正确的,尽管我一直收到错误当我运行我的网站时出现语法错误

   $query = "SELECT DISTINCT paycheck.jobId
      FROM paycheck,users
      WHERE users.email = " . $_SESSION['email'] .
      "AND userId = empId";
4

2 回答 2

5

你在这里忘记了单引号

$query = "SELECT DISTINCT paycheck.jobId
FROM paycheck,users
WHERE users.email = '" . $_SESSION['email'] ."' AND userId = empId";
于 2013-03-16T06:47:45.767 回答
0

尝试这个:

$query = "SELECT DISTINCT `paycheck`.`jobId`
      FROM `paycheck`,`users`
      WHERE `users`.`email` = '" . $_SESSION['email'] ."' AND `userId` = 'empId' ";

您可能还需要考虑转义查询以防止 sql 注入

于 2013-03-16T06:49:49.657 回答