As you can see, I have a query I want to insert variables in.
What’s wrong with my syntax?
$query = "UPDATE house SET epname=".$newtitle" WHERE epid= ".$epid;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are your variables strings? You will want to enclose them in quotes for the purpose of the MySQL query.
Also, you’re missing a concatenation operator (period) after $newtitle.
If you echo out the value of $query, you should see the error:
Assuming that epname is a char/varchar value, and epid is an integer of some sort, you probably want to do this:
If you do not use the mysql_escape_string function around your strings, you are vulnerable to SQL injection attacks