我在下面的mysql查询代码中遇到语法错误

时间:2016-03-19 11:27:41

标签: php mysql

变量声明: -

# Get object's boolean field and toggle it
# @param [Object] mongoid object 
# @param [String, Symbol] flag
# @example 
#  foo = User.find('123')
#  toggle_flag!(object: foo, flag: :bar)

def toggle_flag!(object:, flag:)
  object.update(flag => !object[flag])
  object.save!
end
  

语法错误意外' $ firstname' (T_VARIABLE)第21行

2 个答案:

答案 0 :(得分:3)

试试这个

 $sql = "INSERT INTO people (firstname, surname, id,   
 faculty_of_study, enrolled_course, gender, password, telephone_no, 
email_address) VALUES ('$firstname', '$surname', '$id',  
'$faculty_of_study',
'$enrolled_course', '$gender','$password', '$telephone_no','$email_address')";

答案 1 :(得分:0)

试试这个

$sql = "INSERT INTO people (firstname, surname, id,faculty_of_study, enrolled_course, gender, password, telephone_no, email_address) VALUES ('".$firstname."', '".$surname."', '".$id."', '".$faculty_of_study."',  '".$enrolled_course."', '".$gender."','".$password."', '".$telephone_no."', '".$email_address."')";

并在VALUES之前删除分号。