This question already has an answer here:
I have two php files, one is a file for a PDO Connection and one is a file in which a prepared statement is submitted on this connection:
PDO Connection:
class Connection {
protected $user = "ni873420_2sql1";
protected $pass = "#";
public $pdo_log;
public function __construct() {
try {
$pdo_log = new PDO('mysql:host=localhost;dbname=ni873420_2sql1',
$this->user, $this->pass);
}
catch (Exception $e) {
die($e);
}
}
}
And this is the function where I create the prepared statement:
public static function getInfobyEmailUsername($argemailusername) {
$get_info_query = "SELECT * FROM user WHERE email = ? OR username = ?";
$conn = new Connection();
$getinfostmt = $conn->pdo_log->prepare($get_info_query);
$getinfostmt->execute(array($argemailusername, $argemailusername));
$userinfo = $getinfostmt->fetch(PDO::FETCH_ASSOC);
if (!empty ($userinfo)) {
return $userinfo;
} else {
return false;
}
}
But I keep getting the error:
Fatal error: Call to a member function prepare() on null
I cant find a solution anywhere, can anyone help me with this or at least send a link where I can find the solution?
Thank you!
</div>