php - Syntax error:MySQL Insert Select -


i have query insert tbl_userprofile:

$sql = "insert tbl_userprofile (userid, name, surname, gender, nationality, address,  mobile, department, email, question, answer) select tbl_user.id , '$name', '$surname', '$gender', '$nationality', '$address','$mobile',  '$department', '$email', '$question', '$answer' tbl_user username = '$uname'"; 

i'm getting syntax error saying: "you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'pet-peeve', 'dirt' tbl_user username = 'alex'' @ line 2"

note: pet-peeve , dirt question , answer. dont know how i'm getting syntax error. please syntax error? thanks

there might plain text in 2 last field maybe there quote around, better use addslashes() $question , $answer variables

'$email', '".addslashes($question)."', '".addslashes($answer)."' tbl_user 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -