我的sql有时候还可以,但有时会失败

时间:2013-07-25 02:40:29

标签: php sql

我正在编写php来查询MySQL数据库,但 sql语句有时会运行但有时会失败。**当它工作时,它会返回记录,当它失败时会说:**你有一个你的SQL语法错误。我不知道如何修复它,请给我一个hand.thanks.the * _id和type是整数,其他是字符串或日期类型。

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);
  }
}

0 个答案:

没有答案