title: Express/Node user controller to upload file on server and MySQL throw an SQL syntax error
body: <p>I'm creating an user controller <code>export.update</code> as per below code.</p>
  <p>Once a <code>POST</code> request is submitted on the front end the controller should do the following:</p>
  <ul>
  <li>upload file on folder <code>updload</code>;</li>
  <li>insert name of the picture on the MySql database.</li>
  </ul>
  <p>When I click on submit button the upload of the file is successful on the dedicated folder but no data are transfer to MySql. Instead I get back this message on the terminal:</p>
  <p><code> sqlMessage: &quot;You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE id = '203'' at line 1&quot;, sqlState: '42000', index: 0, sql: &quot;UPDATE user SET first_name='John' ,last_name='Doe', profile_image='rocket-lab-New-Zealand.jpeg',WHERE id = '203'&quot;</code></p>
  <p>Any suggestion/direction on the right path is highly appreciated.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>exports.update = (req, res) =&gt; {
      message = '';
      if (req.method == 'POST') {
          var post = req.body;
          var first_name = post.first_name;
          var last_name = post.last_name;
  
  
          if (!req.files)
              return res.status(400).send('No files were uploaded.');
  
          var file = req.files.profile_image;
  
  
          var profile_image = file.name;
          console.log(profile_image)
          if (file.mimetype == "image/jpeg" || file.mimetype == "image/png" || file.mimetype == "image/gif") {
  
              file.mv('./upload/' + file.name, function (err) {
  
                  if (err)
  
                      return res.status(500).send(err);
  
                  connection.query('UPDATE user SET first_name=? ,last_name=?, profile_image=?,WHERE id = ?', [first_name, last_name, profile_image, req.params.id], (err, rows) =&gt; {
  
                      if (!err) {
                          connection.query('SELECT * FROM user WHERE id = ?', [req.params.id], (err, rows) =&gt; {
                              if (!err) {
                                  res.render('edit-crew', { rows, alert: `${first_name} has been updated.` });
  
                              } else {
                                  console.log(err);
                              }
                              console.log('The data from user table:\n', rows);
                          });
                      } else {
                          console.log(err);
                      }
                      console.log('The data from user table:\n', rows);
                  });
              });
          }
      }
  }</code></pre>
  </div>
  </div>
  </p>