2013-03-23 51 views
0

我有這樣的PHP代碼運行時不執行 - :SET和SELECT查詢在PHP代碼

$q = "SET @session = '1', @buddys = '12,7,10', @rejects = 'post_0'; SELECT f.* FROM feed as f"; $r = mysqli_num_rows($q);. 


這導致了這個錯誤 - :You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT f.* FROM feed as f' at line 3。但是令人驚訝的是,當相同的mysql查詢在phpmyadmin中運行時,它會根據需要運行。

最新情況?感謝您的幫助......

+0

'*'是儲戶mysql符號 – samayo 2013-03-23 20:09:10

回答

0

你的問題是semicolone ;之前選擇

嘗試通過逗號,更換

$q = "SET @session = '1', @buddys = '12,7,10', @rejects = 'post_0' , SELECT f.* FROM feed as f"; 
    $r = mysqli_num_rows($q); 

,或者您也烏爾德這樣分開查詢

$q = "SET @session = '1', @buddys = '12,7,10', @rejects = 'post_0' "; 
    $q .= "SELECT f.* FROM feed as f"; 
+0

它沒有用逗號工作? – 2013-03-23 20:13:23

+0

編輯我的答案, – 2013-03-23 20:19:03