javascript - Update data on mysql using ajax -


i'm trying send id of image when user click on using ajax. in update.php file i'd update id of image. i'm new on ajax, i'm not able figure out error.

$(document).ready(function(){ $('.show_people_image .love').on('click', function() {       var id = $(this).attr('id');      var idpage = "<?php echo $id ?>";     var svar1 = encodeuricomponent(id);     var svar2 = encodeuricomponent(idpage);     var svar3 = "<?php echo $_session['aaa'] ?>";     var svar4 = "<?php echo $_session['bbb'] ?>";       if (svar1 == svar2) {     $.ajax({         type: "post",         url: "update.php",         data: {lid:svar1, ml:svar3, mem:svar4},         success: function(data) {             alert(data);             },         error: function () {         alert('error');         }        });          }  }); }); 

the update.php file is:

if (isset($_post['lid']) , isset($_post['ml']) , isset($_post['mem'])) {  include 'models/connexion_sql.php';   $loveid = $_post['lid'];  if ($_post['ml']) { $str = $_post['ml'].','.$loveid; } else { $str = $loveid; }   $sql = 'update users set myl= :myl email = :email'; $req = $bdd->prepare($sql); $req->bindparam(':email', $_post['mem'], pdo::param_str); $req->bindparam(':myl', $str, pdo::param_str); $req->execute();  echo $str;  }   

if put echo in upload.php file before prepare($sql) request successful, otherwise request fails.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -