2012-11-17 160 views
-1

打破我在PHP MySQL查詢:MySQL查詢在PHP

$query = "SELECT serial FROM code WHERE type='".$type."' AND year='".$year."' AND subject='".$subject."' AND mounth='".$mounth."' AND day='".$day."' ORDER BY serial DESC LIMIT 1"; 

當我贊同它(用於調試)我看到這一點:

SELECT serial FROM code WHERE type='in' AND year='391' AND subject='pcyear=393' AND mounth='04' AND day='1' ORDER BY serial DESC LIMIT 1 

什麼是附近主題的問題='pcyear = 393 ??

請幫助

+1

最新錯誤? – gks

+0

你真的需要說出你看到的錯誤!主題欄的數據類型是什麼? – Stefan

+0

這不是'mounth'中的錯字嗎? –

回答

1

如果你回去echo $subject你會得到pcyear=393

檢查並確保$subject正確分配我打賭。

+0

'pcyear = 393'可能是一個有效的主題,對於我們所知的所有 – Stefan

1

你$主題變量被設置爲subject='pcyear=393