我使用PHP錯誤和PDOSQLSTATE [42000]:語法錯誤或訪問衝突:1064您有
這裏是我的代碼:
try {
$sql="LOCK TABLE appleid WRITE, appleid AS appleid1 READ;";
$stmt = $GLOBALS['$connection']->prepare($sql);
$stmt->execute();
$sql="SELECT MAX(num) FROM appleid;";//to know how many rows it has
$stmt = $GLOBALS['$connection']->prepare($sql);
$stmt->execute();
$result=$stmt->fetch();
$table_top=$result[0];
if (empty($head)) $head = 1;
$check=$table_top - $head;
$check++;//number of available rows that are ready to use
if($check>=$this->apple_id_num)
{
$sql = "SELECT id,pass,en_b_y,en_b_m,en_b_d,sqa1,sqa2,sqa3 FROM
appleid AS appleid1
WHERE num>=$head LIMIT $this->apple_id_num ORDER BY `TimeStamp`
DESC;";
$stmt = $GLOBALS['$connection']->prepare($sql);
$stmt->execute();
$this->pre_head=$head;
$head=1+$head+$this->apple_id_num;
$sql="UNLOCK TABLES;";
$this->num_rows = $stmt->rowCount();
echo $stmt->rowCount();
}
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
我得到這個錯誤:
SELECT id,pass,en_b_y,en_b_m,en_b_d,sqa1,sqa2,sqa3 FROM appleid AS appleid1 WHERE num> = 1 LIMIT 1 ORDER BY
TimeStamp
DESC; SQLSTATE [42000]:語法錯誤或訪問衝突:1064您的SQL語法錯誤;檢查 對應於您的MySQL服務器版本的權利 語法使用近「ORDER BY
TimeStamp
DESC」在列2
我糊塗了,我不知道什麼是錯的這個查詢和手動如何解決它。
噢謝謝你:) – arteem
歡迎:) – Exprator
我是新的堆棧溢出我尋找像或某事,以表明它幫助我,但我無法找到如何接受答案? – arteem