我正在使用带有 PDO 的 PHP
尝试使用电子邮件作为键从表中检索记录。当邮件直接在sql语句中给出时,它工作正常,
但是当我在“$bio_email”字段中发送电子邮件时,它不起作用。表中的电子邮件字段类型为“varchar”
我尝试了几种选择,但都没有。系统返回的错误在 sql 语句的右侧
这是我的代码
$bio_email = $applicantinfo->user_email; // email from a table
$sql = "SELECT * FROM tb_files_upload WHERE ";
$sql .= " email = 'applicant1@live.ca' "; // THIS WORKS FINE
//$sql .= " email = 'danilo.gonzalez@parkinson.ca' "; // THIS WORKS FINE
//$sql .= " email = $bio_email "; // DOES NOT WORK ... syntax to use near '@live.ca' at line 1
//$sql .= " email = {$bio_email} "; // DOES NOT WORK ... syntax to use near '@live.ca' at line 1
//$sql .= " email = '{$bio_email}' "; // DOES NOT WORK ... syntax to use near ''applicant1@live.ca'' at line 1
//$sql .= " email = '$bio_email' "; // DOES NOT WORK ... syntax to use near ''applicant1@live.ca'' at line 1
$biosketchs = Tb_Files_Upload::find_by_sql($sql);
同样在同一张表中,我有一个字段“dateReceived”。我想要 2.5 年前的记录。你能帮我解决这个问题吗?