news表里面有两笔数据,没问题。然后用最简单的PHP语句将其显示出来,却报错了:
/..数据库连接代码,省略
<table>
<?php
$result = mysql_query("SELECT news_title,in_time FROM news");//这里确认是有值的
   while ($row=mysql_fetch_row($result))
{
?>    
        <tr>
          <td>
    <img src="../images/icon.gif" width="7" height="7" />
  <a href="../news/?news_title=$row('news_title')" target="_blank"> //这里的news_title取不到值
  &nbsp;<?php echo "$row('news_title')"; ?>//这里报错,报错内容:Fatal error: Function name must be a string in
  </a> 
  <span class="gray">&nbsp;<?php echo "$row('in_time')"; ?></span>
  </td>
        </tr>
<?php
    }
mysql_free_result($result);
?> 
<table>
百度了一下,无法解决

解决方案 »

  1.   

    百度表示这种问题很多,但是各不相同:http://www.baidu.com/s?tn=baiduhome_pg&ie=utf-8&bs=Fatal+error%3A+Function+name+must+be+a+string&f=8&rsv_bp=1&rsv_spt=1&wd=Fatal+error%3A+Function+name+must+be+a+string&inputT=0
      

  2.   

    //...
    <a href="../news/?news_title=<?php echo $row['news_title']; ?>" target="_blank">
    &nbsp;<?php echo $row['news_title']; ?>
    </a> 
    <span class="gray">&nbsp;<?php echo $row['in_time']; ?></span>
    //...
      

  3.   

    $row是一个数组,所以要用方括号 $row['news_title']
      

  4.   

     <a href="../news/?news_title=$row('news_title')" target="_blank"> //这里的news_title取不到值
                  &nbsp;<?php echo "$row('news_title')"; ?>你下面知道要输出 上面就不知道了?
    然后 php的数组是用 $xxx['xxx'] 不是用 $xxx(xxx)...
      

  5.   


    谢谢,问题解决。又来了新报错:Notice: Undefined index: news_title in 。我知道,这个时候要用=mysql_fetch_asso而不能用=mysql_fetch_row郁闷,我怎么就是纠缠不清这些函数的区别呢