<?php 
$mysql_user = "root"; 
$mysql_password = "123456789"; 
$link = mysql_connect("localhost",$mysql_user,$mysql_password) or die("Could not connect"); 
mysql_select_db('#Phone_DB'); 
?> <?php 
$exec = "Select * from '!phone_post_table'"; 
$result = mysql_query($exec,$link); 
$rs = mysql_fetch_object($result); 
echo $rs[2]; 
?> 
请问我这个有什么错误,怎么网页上什么显示也没有呀,我数据表里确实有数据

解决方案 »

  1.   


    改成如下:
    $exec = "Select * from `!phone_post_table`";
    $result = mysql_query($exec);
    $rs = mysql_fetch_object($result);
    echo $rs[2];
      

  2.   

    对啊,面向对象与面向过程的方法不能混用啊,
    code=PHP]
    $exec = "Select * from `!phone_post_table`";
    $result = mysql_query($exec);
    $rs = mysql_fetch_object($result);
    echo $rs->表中的字段名;[/code]
    试一下!
      

  3.   

    你那个mysql_fetch_object是object,输出却用数组的方式echo $rs[2];  当然没结果啦要么$rs = mysql_fetch_object($result);echo $rs->字段名;要么$rs = mysql_fetch_array($result);echo $rs[下标];