我在Local Wamp上运行了一个PHP文件。它给出了以下错误,
Use of undefined constant length - assumed 'length' in C:\wamp\www\test\newreport.php
我的编码:
<?php
echo "test success";
$con=mysql_connect("localhost", "root", "pass")or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("project1",$con);
$result = mysql_query("select x1, x2, x3, x4, x5, x6, time_format( x7, '%h:%i:%s %p' ) x71, x8 from newstorage") or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($result))
{
$name[$i]=$row['x1'];
$ctime[$i]=$row['x71'];
echo $ctime[$i]."<br>"; // It prints time perfectly
$i++;
}
echo $i.length; // error occurs in this line...
?>
请帮我解决这个问题..
答案 0 :(得分:0)
删除.length
:
<?php
echo "test success";
$con=mysql_connect("localhost", "root", "pass")or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("project1",$con);
$result = mysql_query("select x1, x2, x3, x4, x5, x6, time_format( x7, '%h:%i:%s %p' ) x71, x8 from newstorage") or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($result))
{
$name[$i]=$row['x1'];
$ctime[$i]=$row['x71'];
echo $ctime[$i]."<br>"; // It prints time perfectly
$i++;
}
echo $i;
?>