Jump to content

AndreaJana

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by AndreaJana

  1. I am working on registration form but have problem on 1 linecod: Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\ooploginreg\functions.php on line 13 Call Stack # Time Memory Function Location 1 0.0010 252552 {main}( ) ..\register.php:0 2 0.0030 265480 LoginRegistration->registerUser( ) ..\register.php:50 functions.php <?php require "config.php"; class LoginRegistration{ function __construct() { $database = new DatabaseConnection(); } public function registerUser($username,$password,$name,$email,$website){ global $pdo; $query = $pdo->prepare("SELECT id FROM users WHERE username = ? AND email = ?"); $query->execute(array($username, $email)); $num = $query->rowCount(); if($num == 0){ $query = $pdo->prepare("INSERT INTO users (username, password, name, email, website)VALUES (?, ?, ?, ? ,?)"); $query->execute(array($username, $password, $name, $email, $website)); return true; }else{ return print "<span style='color:=#e53d37'>Error...username/email already used.</span>"; } } } ?> config hope is ok: config.php <?php class DatabaseConnection{ public function _construct(){ global $pdo; try{ $pdo = new PDO('mysql:host=localhost;dbname=oopreg', 'root', ''); } catch (PDOException $e){ exit('Database error'); } } } ?> What do you thik about this error?
  2. Hello there, I am newbie here and seems this is good place. I am working on registration form but have error on 1 linecod: Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\ooploginreg\functions.php on line 13 Call Stack # Time Memory Function Location 1 0.0010 252552 {main}( ) ..\register.php:0 2 0.0030 265480 LoginRegistration->registerUser( ) ..\register.php:50 functions.php PHP Code: <?php require "config.php"; class LoginRegistration{ function __construct() { $database = new DatabaseConnection(); } public function registerUser($username,$password,$name,$email,$website){ global $pdo; $query = $pdo->prepare("SELECT id FROM users WHERE username = ? AND email = ?"); $query->execute(array($username, $email)); $num = $query->rowCount(); if($num == 0){ $query = $pdo->prepare("INSERT INTO users (username, password, name, email, website)VALUES (?, ?, ?, ? ,?)"); $query->execute(array($username, $password, $name, $email, $website)); return true; }else{ return print "<span style='color:=#e53d37'>Error...username/email already used.</span>"; } } } ?> config.php hope is ok: <?php class DatabaseConnection{ public function _construct(){ global $pdo; try{ $pdo = new PDO('mysql:host=localhost;dbname=oopreg', 'root', ''); } catch (PDOException $e){ exit('Database error'); } } } ?> What do you thik about this error?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.