1

I believe I have a issue with in mysql query. Please take a look at the code and let me know if there is something wrong in this statement.

$sql = "UPDATE `Blog` SET `Employee_Name` = '$emp_name', 'Employee_Email' = '$emp_email'      WHERE `Blog`.`Id` = '$emp_id'";
1
  • yes,you are using quotes for column names ,use back ticks.You started fine,than went back to quotes. Commented Apr 10, 2014 at 17:15

1 Answer 1

1

Bad quoting:

$sql = "UPDATE `Blog` SET `Employee_Name` = '$emp_name', 'Employee_Email' = '$emp_email'      
                                                         ^--------------^--- 

The indicated quotes should be backticks (`), not single quotes (').

And if you had proper (or any at all) proper error handling on your query calls, you'd have been told about the syntax error.

Sign up to request clarification or add additional context in comments.

3 Comments

It worked. Im a newbie so thanks for even taking the time. Such a simple mistake.
No worries. But do add error handling. e.g. $result = mysql_query($sql) or die(mysql_error()). Never assume a query succeeded. Always assume failure, and treat success as a pleasant surprise. Even this basic type of "bail out on failure" will help while developing and tell you exactly what went wrong.
If the answers works for you, then mark it as a correct answer so others can benefit from it as well. Aside note, try to write your query in a query editor first (such as SQLYOG) to check it's correctness since the sql tool will format and color highlight your query which will make it easier to detect errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.