2013-05-03 43 views
2

我使用時間戳記updateTag列創建digiCardPass。 我嘗試:如何選擇MAX(updateTag)

$query1 = mysql_query("select MAX(updateTag) as updateTag from digiCardPass"); 
    $row1 = mysql_fetch_array($query1); 
    $updateTag = $row1['updateTag']; 
    error_log("max updateTag:",$updateTag,0); 

但我不能在php_error.log得到這個錯誤:

[03月 - 2013 12時46分06秒亞洲/金邊] PHP的通知:非形成良好在 /Applications/MAMP/htdocs/passesWebserver/createPass/index.php遇到上線 數值 42 [03月 - 2013 12時46分06秒亞洲/金邊]最大updateTag:

//line 42: error_log("max updateTag:",$updateTag,0); 

如何解決這個問題?

+0

哪條線是42寫$updateTag內容? – zerkms 2013-05-03 05:55:55

+0

你有沒有試過回顯'$ updateTag'?它給了什麼。 – 2013-05-03 05:58:10

+0

我只是編輯我的問題,你可以看看! – malinchhan 2013-05-03 06:15:20

回答

2

您的error_log語句不正確,正在導致錯誤消息。在文本和要寫入日誌的變量之間有逗號,因此它將$updateTag視爲error_log命令的第二個參數。

嘗試:

error_log("max updateTag: " . $updateTag, 0); 

擺脫你的警告和日誌

+0

是的,謝謝!但在此之後,什麼也沒有顯示!我必須解決它! – malinchhan 2013-05-03 06:27:18

+1

你的意思是你在日誌中看到'max updateTag:',或者根本沒有?如果什麼都沒有,那麼檢查這個代碼嵌套的條件是否評估爲真。 – PassKit 2013-05-03 06:32:30

+0

是的,我可以看到,但是當我使用此更新標籤選擇其他查詢時,我無法獲得結果! – malinchhan 2013-05-03 06:35:10

1

看看$ row1 ['updateTag'],因爲它可能無法被PHP格式化爲數字。

echo $row1['updateTag']; 
echo floatval($row1['updateTag']); 

確認updateTag是一個數字。

+0

但updateTag是時間戳! – malinchhan 2013-05-03 06:13:21

-1
error_log("max updateTag:",1,$updateTag); // second var is type 0-3 

Optional. Specifies the error log type. 
Possible log types: 
0 - Default. The error is sent to the servers logging system or a file, depending on how the error_log configuration is set in the php.ini file 
1 - The error is sent by email to the address in the destination parameter. This message type is the only one that uses the headers parameter 
2 - The error is sent through the PHP debugging connection. This option is only available in PHP 3 
3 - The error is added to the file destination string 
+0

'$ updateTag'不包含文件名,因此不是有效的目標參數。其目的似乎是將可變內容回顯到日誌中,並且您的代碼會將「max updateTag:」寫入具有$ updateTag變量內容名稱的文件名。 – PassKit 2013-05-03 06:28:16