简体   繁体   中英

Cannot select first name and group from DB:

My code for select is this:

$user_check_query="SELECT first_name,group FROM users WHERE username=?";
$query=$bd->prepare($user_check_query);
$query->bind_param('s',$username);
$query->execute();
$query->bind_result($first_name,$group);
$query->fetch();

The error is - Fatal error: Call to a member function bind_param() on a non-object in C:\\xampp\\htdocs\\project1\\test.php on line 9, at line 9 is the bind_param. The fields into the database are not empty and here their screenshot: http://prikachi.com/images/786/7271786g.png The table is users, i've checked that.

group is a reserved key word. You need to backtic it as

`group`


SELECT first_name,`group` FROM users WHERE username=?

http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM