2013-01-20 62 views
-3

我已經運行到有點用PHP MAIL命令 的問題。當我去處理它,它只是返回一個錯誤頁面。(不SQL)PHP郵件命令

這裏是我的代碼遠

$getdisputes = mysql_query("SELECT * FROM `disputedetails` WHERE `invno` = '$invoiceno'") or die(mysql_error()); 
//send email 
$to = "".$disputeemail.""; 
$subject = "Dispute submitted"; 
$from = "[email protected]" 
$headers = "From:" . $from; 
$message1 = "Store ".$username. " has submitted a dispute on invoice number ".$invoiceno; 
// foreach line in disputedetails file for that invoice number, add to $message item, desc and 
while ($info = mysql_fetch_array($getdisputes)) { 
    $message = $message1 + "\n <b>Invoice Number: </b>".$info['invno']." <b>Item ID:</b> ".$info['itemid']." <b>Description: </b>".$info['description']." <b>Disputed Quantity:</b> ".$info['disputeqty']." Reason: ".$info['reason']."."; 
} 
mail($to,$subject,$message,$headers); 

任何想法是什麼造成的問題?

+3

,什麼是錯誤?如果沒有SQL結果,那麼while循環將不會執行,並且'$ message'永遠不會被設置。 – sachleen

+0

更具體一點,我們現在不看你的電腦。 –

+1

這是我見過的最可笑的PHP行:'$ to =「」。$ disputeemail。「」;' – keyboardSmasher

回答

1

變化

$message1 = "Store ".$username. " has submitted a dispute on invoice number ".$invoiceno; 
// foreach line in disputedetails file for that invoice number, add to $message item, desc and 
while ($info = mysql_fetch_array($getdisputes)) { 
    $message = $message1 + "\n <b>Invoice Number: </b>".$info['invno']." <b>Item ID:</b> ".$info['itemid']." <b>Description: </b>".$info['description']." <b>Disputed Quantity:</b> ".$info['disputeqty']." Reason: ".$info['reason']."."; 
} 

分爲:

$message = "Store ".$username. " has submitted a dispute on invoice number ".$invoiceno; 

while ($info = mysql_fetch_array($getdisputes)) 
    $message .= "\n <b>Invoice Number: </b>".$info['invno']." <b>Item ID:</b> ".$info['itemid']." <b>Description: </b>".$info['description']." <b>Disputed Quantity:</b> ".$info['disputeqty']." Reason: ".$info['reason']."."; 
3
$from = "[email protected]" 

該行存在錯誤。您需要以「;」結尾分號

像這樣:

$from = "[email protected]"; 
+0

已修復!謝謝你,我一定很累。 –

+0

更糟糕的是,你必須有檢查錯誤\顯示或它會指出你的權利。 – 2013-01-20 22:04:12