سؤال

I create digiCardPass with updateTag column that is timestamp. I try:

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

But I cannot get this error in php_error.log:

[03-May-2013 12:46:06 Asia/Phnom_Penh] PHP Notice: A non well formed numeric value encountered in /Applications/MAMP/htdocs/passesWebserver/createPass/index.php on line 42 [03-May-2013 12:46:06 Asia/Phnom_Penh] max updateTag:

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

How to solve this problem ?

هل كانت مفيدة؟

المحلول

Your error_log statement is incorrect and is causing the error message. You have a comma between your text and the variable that you want to write to the log, so it is treating the $updateTag as the second parameter of the error_log command.

Try:

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

to get rid of your warning and write the contents of $updateTag in the log

نصائح أخرى

Take a look at $row1['updateTag'] as it probably can't be formatted as a number by PHP.

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

Get sure updateTag is a number.

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top