0

我在我的测试站点http://www.weddingsplanner.co.in/test/收到了这么多错误

这是 index.php 的代码,我在页​​面 db.php 中遇到错误,但我认为如果我能从这里找到一些问题,它会解决

 <?php

    require_once 'config.php';

    function __autoload($class_name) 
    {
        include_once 'library/' . strtolower($class_name) . '.php';
    }

    $user = new User();

    $facebook = new Facebook(array(
      'appId'  => FB_ID,
      'secret' => FB_SECRET,
    ));

    if ($user->isLogged())
    {
        $registerOrLoginNeeded = false;
    }
    else
    {
        $registerOrLoginNeeded = true;

        /*
            To disable auto login, comment the code used to login automatically. 
            (Must be used together with documented changes in JavaScript)
            Start Here.
        */
        $fbUser = $facebook->getUser();

        if ($fbUser) 
        {
            try {

                $userProfile = $facebook->api('/me');

                if ($user->fbLogin($fbUser)) 
                {
                    $registerOrLoginNeeded = false;
                }
                else
                {
                    $db = Db::init();

                    $sth = $db->prepare("SELECT * FROM users WHERE email = ?");
                    $sth->execute(array($userProfile['email']));

                    if (false != $sth->fetch())
                    {
                        $sth = $db->prepare("UPDATE users SET facebook = ? WHERE email = ?");
                        if ($sth->execute(array($fbUser, $userProfile['email'])))
                        {
                            if ($user->fbLogin($fbUser))
                                $registerOrLoginNeeded = false;
                        }
                    }
                }

            } catch (FacebookApiException $e) {
                $fbUser = null;
            }
        }
        /*
            End Commenting Here
        */
    }   
?>

<!DOCTYPE html>

<html lang="en-US">
    <head>
        <title>Simple Registration System</title>
        <style>
            body { font: normal 14px Verdana; }
            h1 { font-size: 24px; }
            h2 { font-size: 18px; }
        </style>
    </head>
    <body>

        <div id="wrap">

            <section id="main">

                <?php if (false === $registerOrLoginNeeded): ?>

                    <h1>Welcome</h1>
                    <p>You may now enjoy the site.</p>
                    <a href="logout.php">Logout</a>

                <?php else: ?>

                    <div id="fb-root"></div>
                    <script type="text/javascript">
                      window.fbAsyncInit = function() {
                        FB.init({
                          appId      : '<?php echo $facebook->getAppID() ?>', // App ID
                          channelUrl : 'http://localhost.com/channel.html', // Channel File
                          status     : true, // check login status
                          cookie     : true, // enable cookies to allow the server to access the session
                          oauth      : true, // enable OAuth 2.0
                          xfbml      : true  // parse XFBML
                        });
                        FB.Event.subscribe('auth.login', function(response) {
                            /*
                                To have user login when FB login button is clicked
                                comment window.location.reload(); line and 
                                uncomment the window.location = "fb_login.php";
                                line. Must be used together with commenting the PHP part
                            */
                            window.location.reload();
                            //window.location = "fb_login.php";
                        });
                        FB.Event.subscribe('auth.logout', function(response) {
                          window.location.reload();
                        });
                      };
                      (function(d){
                         var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
                         js = d.createElement('script'); js.id = id; js.async = true;
                         js.src = "//connect.facebook.net/en_US/all.js";
                         d.getElementsByTagName('head')[0].appendChild(js);
                       }(document));
                    </script>

                    <h1>Registration or login needed</h1>

                    <div style="float: left; margin-right: 15px;">

                        <h2>Register</h2>
                        <p>You need to register to fully enjoy this site.</p>

                        <div class="fb-registration" 
                          data-fields='[{"name":"name"},
                                        {"name":"birthday"},
                                        {"name":"location"},
                                        {"name":"gender"},
                                        {"name":"email"},
                                        {"name":"username","description":"Username","type":"text"},
                                        {"name":"password"}]' 
                            data-redirect-uri="http://localhost.com/register.php"
                          width="300">
                        </div>

                    </div>

                    <div style="float: left;">

                        <h2>Login</h1>
                        <p>
                            If you already have an account you can login 
                            using the form below:
                        </p>
                        <form action="login.php" method="POST">
                            <div>
                                <label for="username">Username:</label>
                                <input type="text" id="username" name="username" />
                            </div>
                            <div>
                                <label for="password">Password:</label>
                                <input type="password" id="password" name="password" />
                            </div>
                            <div><input type="submit" value="Login" /></div>
                            <p>
                                If you previously registered for this site using Facebook, 
                                you can now login using your Facebook account.
                            </p>
                            <div class="fb-login-button" data-show-faces="false" scope="email"></div>
                        </form>

                    </div>
                    <div style="clear:both;">&nbsp;</div>

                <?php endif; ?>

            </section>

        </div>

    </body>
</html>

这是 db.php 的代码

<?php

class Db
{
    private static $db;

    public static function init()
    {
        if (!self::$db)
        {
            try {
                $dsn = 'mysql:host='.DB_HOST.';dbname='.DB_NAME;
                self::$db = new PDO($dsn, DB_USER, DB_PASS);
                self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            } catch (PDOException $e) {
                // Normally, we would log this
                die('Connection error: ' . $e->getMessage() . '<br/>');
            }
        }
        return self::$db;
    }
}
4

2 回答 2

0

正如在http://www.weddingsplanner.co.in/test/library/上看到的,它没有列出文件pdo.php

它试图包含在您的代码的这一行中:

function __autoload($class_name) 
{
    include_once 'library/' . strtolower($class_name) . '.php';
}

验证您的文件夹并上传必要的文件,错误应该得到修复!

于 2013-04-09T11:57:59.337 回答
0

请检查您的库文件夹中是否存在 pdo.php 文件。__autoload 函数尝试加载未定义的类。必须调用名为 pdo 的类。请核实。

于 2013-04-09T11:55:34.717 回答