سؤال

im trying to write OAuth class for VK to be able to authenticate users on my website. The problem i faced, is that the code i wrote on Windows, is not working at all on Linux.

I've successfully connected to my Linux Database through PHP->PDO script, but the problem is, that any function im trying to execute, im unable to get response or query, just nothing happening.

Here is the example of function:

Class Account
{
    private $Connection;
    private $ErrorHandler;
    private $Template;

    public function __construct()
    {
        global $DB, $Error, $Smarty;
        $this->Connection = $DB->DBConnection;
        $this->Template = $Smarty;
        $this->ErrorHandler = $Error;
    }
public function CheckDataWithVK($Username, $First_Name, $Last_Name, $Birth_Date)
{
        $StatementHandler = $this->Connection->prepare("SELECT username,email,first_name,last_name FROM account WHERE username LIKE :username OR first_name LIKE :fname AND last_name LIKE :lname");
        $StatementHandler->execute(array(':username' => $Username, ':fname' => $First_Name, ':lname' => $Last_Name));
        $Result = $StatementHandler->fetch(PDO::FETCH_ASSOC);
        if($Result['username'] == $Username)
        {
            $BuildUserNameArray = array('Username' => $Username, 'Email' => $Result['email'], 'Name'=> $Result['first_name'], 'Surname' => $Result['last_name']);
            return $BuildUserNameArray;
        }
        else
        {
            if($Result['first_name'] == $First_Name && $Result['last_name'] == $Last_Name)
            {
                $BuildCredentialsArray = array('Username' => $Result['username'], 'Email' => $Result['email'], 'Name'=> $First_Name, 'Surname' => $Last_Name);
                return $BuildCredentialsArray;
            }
            else
            {
                return false;
            }
        }
}

So on Windows, im able to get all the data and to check if user exists in database, but not on Linux.

Let me be selfish and say that im geek in this kind of thing, but even PDO returns no exceptions, so im unable to track flow of data and where error occurs.

I've already checked logs, but it seems that statement is not even executed...

Any help? Thanks in advance

By the way, im using same classes on all my websites, and it is only one which behaves like this.... And yes, i tripple checked all settings, everything is correct. Plus, im using:

$this->DBConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

So at least, if there is Exception, i should see something, but i see nothing -> no Exceptions

Here is my Database.Class.php:

public $DBConnection;
private $Template;

public function __construct($username, $password, $database)
{
    global $Smarty;
    $this->Template = $Smarty;
    try
    {
        $this->DBConnection = new PDO("mysql:host=127.0.0.1;dbname=".$database, $username, $password, array(PDO::ATTR_PERSISTENT => true));
        $this->DBConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }
    catch(PDOException $e)
    {
        $message = $e->getMessage();
        $this->Template->assign('ErrorHeader', $this->Template->getConfigVars('DatabaseError'));
        $this->Template->assign('ErrorMessage', $e->getMessage());
        $this->Template->Display('ErrorHandler.tpl');
        echo "<!-- FreedomCore Servers: PDO Connection Error: $message -->\n";
        die();
    }
}

My bad, forgot to mention.... Idiot.... I'm able to insert values, but there is problem with this particular function

هل كانت مفيدة؟

المحلول

Problem was solved by updating server PHP Library to 5.5.12 version.

On Windows i've been using 5.5.5, on Linux 5.4.4, i think that what caused the problem

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top