简体   繁体   中英

Simple SQL query in PHP

I'd like to know if my query is correctly written as I think I've mad an error at " responsible_internship_teacher=true "

public function teacher_responsibility($email_teacher){
    $query = "SELECT 
                     * 
              FROM 
                     teachers 
              WHERE 
                     email_teacher='$email_teacher' AND 
                     responsible_internship_teacher=true";
    $result = $this->_db->query ($query);
    return $result->rowcount();
}

thanks for your help.

could be you have true like a string then use single quotes around the string

'true'

"SELECT 
                 * 
          FROM 
                 teachers 
          WHERE 
                 email_teacher='$email_teacher' AND 
                 responsible_internship_teacher='true'";

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