【问题标题】:how to select MAX(updateTag)如何选择 MAX(updateTag)
【发布时间】:2013-05-03 05:52:13
【问题描述】:

我使用作为时间戳的 updateTag 列创建 digiCardPass。 我试试:

   $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] 最大更新标签:

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

如何解决这个问题?

【问题讨论】:

  • 您是否尝试过回显$updateTag?它给了什么。
  • 我只是编辑我的问题,你可以看看!

标签: php mysql passbook mysql-select-db


【解决方案1】:

您的 error_log 语句不正确并导致错误消息。您的文本和要写入日志的变量之间有一个逗号,因此它将$updateTag 视为error_log 命令的第二个参数。

试试:

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

摆脱您的警告并将$updateTag的内容写入日志

【讨论】:

  • 好的,谢谢!但在那之后,什么都没有显示!我得把它修好!
  • 您的意思是您在日志中看到max updateTag:,还是什么也没有?如果什么都没有,则检查此代码嵌套的任何条件是否为真。
  • 是的,我可以看到,但是当我使用这个 updateTag 在其他查询中选择时,我无法得到结果!
  • 你的其他查询是如何使用它的?
  • 我在 where 条件下使用它。这是查询:select passTypeID,authenticationToken as auth,auxiliaryFieldsPowerBy as aux,associatedStoreIdentifiers asso,altTextBarcode as alt from digiCardPass where updateTag = '$updateTag'
【解决方案2】:

看看 $row1['updateTag'] 因为它可能无法被 PHP 格式化为数字。

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

确保 updateTag 是一个数字。

【讨论】:

    【解决方案3】:
    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
    

    【讨论】:

    • $updateTag 不包含文件名,因此不是有效的目标参数。目的似乎是将变量内容回显到日志中,并且您的代码会将“max updateTag:”写入具有 $updateTag 变量内容名称的文件名。
    猜你喜欢
    • 2020-02-18
    • 2011-12-11
    • 2013-09-11
    • 2014-10-16
    • 1970-01-01
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 2015-01-10
    相关资源
    最近更新 更多