MySQL Forums
Forum List  »  PHP

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_name' in 'where clause'
Posted by: John Biddulph
Date: June 02, 2018 06:54AM

Please help, I am getting the error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_name' in 'where clause'

here is my code:

[php]
<?php
class USER
{
private $db;

function __construct($DB_con)
{
$this->db = $DB_con;
}

public function register($fname,$lname,$uname,$umail,$upass)
{
try
{
$new_password = password_hash($upass, PASSWORD_DEFAULT);

$stmt = $this->db->prepare("INSERT INTO `users1`(`user_name`,`user_email`,`user_pass`)
VALUES(:uname, :umail, :upass)");

$stmt->bindparam(":uname", $uname);
$stmt->bindparam(":umail", $umail);
$stmt->bindparam(":upass", $new_password);
$stmt->execute();

return $stmt;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}

public function login($uname,$umail,$upass)
{
try
{
$stmt = $this->db->prepare("SELECT * FROM `users1` WHERE `user_name`=':uname' OR `user_email`=':umail' LIMIT 1");
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
if($stmt->rowCount() > 0)
{
if(password_verify($upass, $userRow['user_pass']))
{
$_SESSION['user_session'] = $userRow['user_id'];
return true;
}
else
{
return false;
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}

public function is_loggedin()
{
if(isset($_SESSION['user_session']))
{
return true;
}
}

public function redirect($url)
{
header("Location: $url");
}

public function logout()
{
session_destroy();
unset($_SESSION['user_session']);
return true;
}
}
?>
[/php]

Options: ReplyQuote


Subject
Written By
Posted
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_name' in 'where clause'
June 02, 2018 06:54AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.