MySQL Forums
Forum List  »  PHP

Re: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_name' in 'where clause'
Posted by: Sean Westerfield
Date: June 22, 2018 03:06PM

I'm not in a position to recreate and test your whole example, but I'm noticing a couple of things that may be causing your issue:


1) Your use of single quotes around the parameters in the WHERE clause could be throwing things off. Try this:

$stmt = $this->db->prepare("SELECT * FROM `users1` WHERE `user_name`= :uname OR `user_email` = :umail LIMIT 1");



2) You haven't bound the parameters to the SELECT statement. You bound them for the INSERT, but that is a completely separate function. Try this:

$stmt = $this->db->prepare("SELECT * FROM `users1` WHERE `user_name`=':uname' OR `user_email`=':umail' LIMIT 1");
$stmt->bindparam(":uname", $uname, PDO::PARAM_STR);
$stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));


I hope that helps!

Options: ReplyQuote


Subject
Written By
Posted
Re: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_name' in 'where clause'
June 22, 2018 03:06PM


Sorry, you can't reply to this topic. It has been closed.

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.