php echo 结果保存,PHP echo仅返回1位数结果(PHP echo only returning 1 digit results)

该博客讨论了在Joomla 2.5环境中,PHP echo语句仅返回字符串第一个字符的问题。作者提到当查询数据库时,查询结果正常,但在代码整合到Joomla框架时,结果被截断为单个数字。解决方法是去掉对字符串数组元素的索引操作[0],以便正确显示完整计数结果。
摘要由CSDN通过智能技术生成

PHP echo仅返回1位数结果(PHP echo only returning 1 digit results)

当我查询数据库本身时,两个查询都返回正确数量的结果。 但是,当我将此代码放入Joomla 2.5时,它只返回到数字9.然后,如果有更多,它将只显示第一个数字。 所以,基本上,11应该是结果,但它只会显示1.请帮忙!

SELECT count( * ) as column_name FROM `db`

WHERE column_name >= DATE_FORMAT(NOW('0000-00-00'), '%Y-%m-01')

PHP中的回声: <?php echo $column_name [0]; ?> <?php echo $column_name [0]; ?>

When I query the DB itself, both queries return the correct number of results. However, when I drop this code into Joomla 2.5, it will only return up to the number 9. After that, if there's more, it will only display the first digit. So, basically, 11 should be the result, but it will only display 1. Please help!

SELECT count( * ) as column_name FROM `db`

WHERE column_name >= DATE_FORMAT(NOW('0000-00-00'), '%Y-%m-01')

The echo within the PHP: <?php echo $column_name [0]; ?>

原文:https://stackoverflow.com/questions/24289876

更新时间:2019-12-21 11:12

最满意答案

只需使用<?php echo $column_name; ?> <?php echo $column_name; ?> ,你添加的[0]意味着“字符串的第一个字符”,所以你会得到1为12,或4为42。

Just use <?php echo $column_name; ?>, the [0] you've added means "the first character of the string", so you'll receive 1 for 12, or 4 for 42.

2014-06-18

相关问答

您的代码中存在拼写错误。 使用MYSQLI_ASSOC而不是MYSQL_ASSOC 。 其余的代码是正确的。 There is a typo in your code. Use MYSQLI_ASSOC instead of MYSQL_ASSOC. The rest of the code is correct.

我想你可能只是将php文件加载为flash中的文本文件。 你能改变以下几行吗? new URLRequest("checkScores.php");

类似于: new URLRequest("http://localhost/checkScores.php");

或者你在浏览器地址栏中看到的任何内容,就像你在问题中所说的那样“运行”它。 I think you may just be loading up the php file as a text file from flash. Can

...

你所能做的就是在你的PHP脚本中尝试刷新所有当前输出到用户的浏览器,这是对ob_flush的调用,但它实际上也取决于其他许多事情。 HTTP服务器有自己的缓冲区,浏览器可能不会立即渲染它收到的每个数据包。 它就像是一个很长的缓冲区管道,在浏览器中看到任何东西之前,所有的缓冲区都必须刷新,并且PHP输出缓冲区处于最高级别。 All you could do in your PHP script to try to flush all the current output to the user's

...

像这样的东西? 您的代码中也存在语法错误。 失踪 ; echo命令结束时的分隔符。

<?php echo $row['Naam'].'
Happy Birthday!'; ?><?php echo $row['Afdeling']; ?>

Something like this? You had syntax error in your code aswell. Missing ; delimiter at end of echo command.

...

如评论中所述: 这是表语法的示例

ABC
123

你最终使用的是什么: echo '

'.$row['lastLogin'].'
';

As stated in comments: This

...

你正在寻找microtime() http://php.net/microtime 如果您想从特定日期创建microtime,只需添加000 。 因为最后,microtime只有1秒。 You are looking for microtime() http://php.net/microtime If you want to create microtime from a specific date, just add 000. Because in the end, the microtime

...

你必须根据变量的数量来改变你的查询。 解决方案可能是 <?php

$parms = array(

'var1' => $_GET['variable1'],

'var2' => $_GET['variable2'],

'var3' => $_GET['variable3'],

);

if (isset($_GET['variable4'])) $parms['var4'] = $_GET['var4'];

if (i

...

您可能将错误日志记录配置为路由到屏幕以外的其他位置。 尝试从shell运行脚本,看看是否输出任何错误。 $bash: php script.php

通常情况下,如果浏览器不这样做,那将会给您带来错误。 You may have error logging configured to route somewhere else other than to the screen. Try running your script from shell and see if that outputs an

...

我相信问题依赖于test_model addResult()方法。 检查那里是否有另一个echo语句。 “成功/”之前的字符串看起来像时间。 也许你在那里回应一个值用于测试目的。 I believe the problem relies in the addResult() method of your test_model. Check to see if there is another echo statement in there. The string before "success/"

...

只需使用<?php echo $column_name; ?> <?php echo $column_name; ?> ,你添加的[0]意味着“字符串的第一个字符”,所以你会得到1为12,或4为42。 Just use <?php echo $column_name; ?>, the [0] you've added means "the first character of the string", so you'll receive 1 for 12, or 4 for 42.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值