Error in OOPLogin/Register . Please help!

+1 Sakshi Dhawan · December 10, 2014
Hi

I am having this problem, testing the oop login system on my local test server: 

Notice: Array to string conversion in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\AA\classes\DB.php on line 13 

Notice: Array to string conversion in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\AA\classes\DB.php on line 13 

Warning: PDO::__construct() expects parameter 2 to be string, array given in C:\Program Files\EasyPHP-DevServer-14.1VC9\data\localweb\AA\classes\DB.php on line 13 

The code line 11-17 DB.php 
private function __construct() { 
try { 
$this->_pdo = new PDO('mysql:host=' . Config::get('127.0.0.1') . ';dbname=' . Config::get('lr'), Config::get('root'), Config::get('')); 
} catch(PDOExeption $e) { 
die($e->getMessage()); 





//init.php 

<?php 
session_start(); 

// Create a global configuration 
$GLOBALS['config'] = array( 
'mysql' => array( 
'host' => '127.0.0.1', 
'username' => 'root', 
'password' => '', 
'db' => 'lr' 
), 
'remember' => array( 
'cookie_name' => 'hash', 
'cookie_expiry' => 604800 
), 
'session' => array( 
'session_name' => 'user', 
'token_name' => 'token' 

); 

// Autoload classes 
function autoload($class) { 
require_once 'classes/' . $class . '.php'; 

spl_autoload_register('autoload'); 

// Include functions 
require_once 'functions/sanitize.php'; 

// Check for users that have requested to be remembered 
if(Cookie::exists(Config::get('remember/cookie_name'))) { 
$hash = Cookie::get(Config::get('remember/cookie_name')); 
$hashCheck = DB::getInstance()->get('users_session', array('hash', '=', $hash)); 

if($hashCheck->count()) { 
$user = new User($hashCheck->first()->user_id); 
$user->login(); 






Please help me with the same. 

Thanks 
Sakshi Dhawan

Post a Reply

Replies

Oldest  Newest  Rating
0 Steven the awesome · December 18, 2014
Please use code tags! 
0 Ricky singh · December 18, 2014
hey sakshi i am also making an oop php login and registration application right now,  so feel free to add me and ask further question

btw change your  code at line 

$this->_pdo = new PDO('mysql:dbname=' . config::get('mysql/db') . ';host=' . config::get('mysql/host'),config::get('mysql/username'),config::get('mysql/password'));
  • 1

PHP

107,004 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators