2013-05-04 100 views
-1

我正在爲項目製作一個shoppingcart.php文件,該文件由同一項目中另一個名爲「catalog.php」的文件提供信息。我堅持的東西是if語句在while循環中(它應該通過來自catalog.php的傳入表單數據循環)。出於某種原因,它不是這樣的:在一個if語句中多次檢查的PHP語法

//Loop through each form field (this page is called from catalog.php):   

    //If form field’s value (product quantity) is a positive number 
//(nonzero), is NOT the submit button, AND the remove checkbox for 
//removing this product has NOT been checked (do these checks in one 
    //condition):   
    while (list($productID,$qty) = each($_POST)){ 
     if(($qty > 0) && (type != submit) && (checkbox != isset())){ 

     }    
    } 

我的if語句有什麼問題?

+0

什麼是錯誤訊息? – Jocelyn 2013-05-04 18:11:57

+0

是否存在沒有'$'的變量? – 2013-05-04 18:13:14

+0

(type!= submit)&&(checkbox!= isset())它是什麼? – qisho 2013-05-04 18:14:38

回答

2

您錯誤地使用了php的isset()isset()需要一個變量參數,並且「[確定]是否設置了變量並且不是NULL」。

試試這個:

if (($qty > 0) && ($type != 'submit') && !isset($checkbox)) { 

} 
+0

錯誤工具提示說:「語法錯誤:expected:::,(」。我應該在某處有一個「::」嗎? – 2013-05-04 18:17:29

+0

@SamPeterson錯誤發生在什麼行號?什麼是代碼那行號? – Aiias 2013-05-04 18:23:36

+0

第47行if語句相同。如果我上傳了整個購物車php文件,它會有幫助嗎? – 2013-05-04 18:31:36