Q: Query not executed, but no errors <?php

require('conn.php');

session_start();

ini_set('default_charset', 'UTF-8');

conopen();

mysql_query("SET NAMES utf8;");
$idedit = $_SESSION['id'] ;
$firstname = mysql_real_escape_string($_POST['firstnameedit']);
$lastname = mysql_real_escape_string($_POST['lastnameedit']);
$email = mysql_real_escape_string($_POST['emailedit']);
$username = mysql_real_escape_string($_POST['usernameedit']);
$password = mysql_real_escape_string($_POST['passwordedit']);


$query = " UPDATE `users` SET `firstname`= '" . $firstname . "',`lastname`='" . $lastname . "',`email`='" . $email . "',`username`='" . $username . "',`password`='" . $password . "', WHERE id = '" . $idedit . "'";
if (mysql_query($query) === true) {
   echo '<meta http-equiv="Refresh" content="0; URL=profile.php" />';
} 
else {
echo 'wrong';
}

conclose();
?>

I don't know why the echo output is incorrect. Can anyone tell me what's wrong? I'm trying to redirect to profile.php. What could be causing the query to return false?

A: You have an extra comma before the where clause.
Try this:
$query = " UPDATE `users` SET `firstname`= '" . $firstname . "',`lastname`='" . $lastname . "',`email`='" . $email . "',`username`='" . $username . "',`password`='" . $password . "' WHERE id = '" . $idedit . "'";

In general, you should learn to print out the query after variable substitution to see what the real query is.  Errors are usually obvious when you do this.

A: I think the problem is the comma in front of the WHERE in your query.
