Как выбрать MAX(updateTag)

Я создаю digiCardPass с колонкой 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-May-2013 12:46:06 Asia / Phnom_Penh] Примечание PHP: неверно сформированное числовое значение, встречающееся в /Applications/MAMP/htdocs/passesWebserver/createPass/index.php в строке 42 [03-May-2013 12:46:06 Asia/Phnom_Penh] max updateTag:

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

Как решить эту проблему?

3 ответа

Решение

Ваш оператор error_log неверен и вызывает сообщение об ошибке. У вас есть запятая между вашим текстом и переменной, которую вы хотите записать в журнал, поэтому он обрабатывает $updateTag в качестве второго параметра команды error_log.

Пытаться:

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

чтобы избавиться от вашего предупреждения и написать содержание $updateTag в журнале

Посмотрите на $row1['updateTag'], так как он, вероятно, не может быть отформатирован как число в PHP.

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

Убедитесь, что updateTag - это число.

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
Другие вопросы по тегам