echo在页面上显示任何内容

时间:2014-03-08 19:01:48

标签: php html css

我正在尝试在数据库中打印数据但是echo不显示任何内容。请指导。感谢。

 <?php 

    require_once("./include/fg_membersite.php");

    $fgmembersite = new FGMembersite();

    //Provide your site name here
    $fgmembersite->SetWebsiteName('user11.com');

    //Provide the email address where you want to get notifications
    $fgmembersite->SetAdminEmail('user11@user11.com');

    //Provide your database login details here:
    //hostname, user name, password, database name and table name
    //note that the script will create the table (for example, fgusers in this case)
    //by itself on submitting register.php for the first time
    $fgmembersite->InitDB(/*hostname*/'localhost',
                          /*username*/'xxxxxxx',
                          /*password*/'xxxxx',
                          /*database name*/'xxxxx',
                          /*table name*/'xxxx');

    // and put it here
    $fgmembersite->SetRandomKey('qSRcVS6DrTzrPvr');

    $result = mysqli_query($fgmembersite,"SELECT * FROM fgusers3");
    echo $result;

    /*
    while($row = mysqli_fetch_array($result))
      {
            if ((isset($_GET['id']))) echo "id is ".$_GET['id'];
        else
            echo "<br> enter id in parameter";  
      }
    */
    ?>

2 个答案:

答案 0 :(得分:1)

如果返回某个对象,则尝试回显该对象,如果没有返回任何内容则返回false。在这两种情况下,echo都不会显示任何内容。

相反,请尝试

print_r($result); 

或者更好的是通过输出到日志文件进行调试

答案 1 :(得分:0)

你也应该运行一些mysqli错误检查

var_dump($result);

if (!$result) {
        echo "<p>There was an error</p>";
        echo $mysqli->error;
}