0

我正在编写 php 来查询 MySQL 数据库,但是sql 语句有时有效,但有时会失败。**当它工作时,它会返回记录,当它失败时它会说:**你的 SQL 语法有错误。我不知道如何解决它,请帮帮我。谢谢。*_id 和类型是整数,其他是字符串或日期类型。

function getMyAwardRecords()
 {
global $db, $userId, $nickName;

$result0 = $db->fetchrows("SELECT user_nick,type,create_date FROM records WHERE type=0 AND user_id={$userId}");
// echo $userId;
$result = $db->fetchrows("SELECT records.user_nick, records.type, records.create_date, awards.code FROM records, awards WHERE records.award_id = awards.award_id AND records.user_id = {$userId}");
$result = array_merge($result, $result0);
// print_r($result);
if($result)
{
    echo ajaxResponse(200,$result);
}
else
  {
    echo ajaxResponse(400);
  }
}
4

0 回答 0