jquery - Ajax and PHP not updating database -
this ajax code gets called, tested it, database not updated. think code small enough not need further explanation. when class pdb gets clicked, saves source database.
$(function(){ $('.pdb').on('click',function(){ var sou = $(this).attr('src'); var iddo = $(this).attr('id'); var data = 'id='+iddo+'&value='+sou+'&turno='+(bia)?true:false; $.ajax({ data: data, type: "post", url: "database.php", success: function(data){ alert("prova: " + data); } }); }); }); database.php
<?php mysql_connect("localhost","pierostesting",""); mysql_select_db("my_pierostesting"); $id=$_post['id']; $value =$_post['value']; $turno=$_post['turno']; if(true){ $sql="update board set $id=$value, turno=$turno partita=0"; $result=mysql_query($sql); if($result){ echo "nailed it"; } }else{ } ?>
remove
var data = 'id='+iddo+'&value='+sou+'&turno='+bia; and debug ajax calls use either console or firebug extension
Comments
Post a Comment