2011-11-03 64 views
0

我已經在本地Wamp上運行PHP文件。它提供了以下錯誤,未定義的恆定長度錯誤在本地wamp

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

刪除.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; 
?>