局部wamp中未定义的常量长度错误

时间:2011-11-03 12:17:37

标签: php wamp

我在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...


?>

请帮我解决这个问题..

1 个答案:

答案 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;
?>