javascript - Mysql UPDATE using PHP and AJAX, can't update database -


after following several examples website think i'm still can't.

i have code:

html

... <a href="javascript:void(0);" class="button red big" style="font-size:24px;" onclick="update_it(<?=$_request["yeah"]["id"];?>);">pay</a> ... 

ajax

function update_it(n_id){     $.ajax({         type: 'post',         url: 'update_yes.php',         data: {idd: n_id},         success: function(output)          {             alert('updated, server says '+n_id);         }, error: function()         {             alert('wrong!');         }     }); } 

php

<?php     $link = mysqli_connect("localhost", "root", "****", "****");      $sql = "delete stuff id = " .$_post["idd"];     mysqli_query($link,$sql) or die(mysql_error());  ?> 

and works php (i think). because can see how html works , how ajax function return success message, still nothing happens in database.

i tried different structures in data field of ajax function data: 'idd': n_id, or data: 'idd=' n_id, nothing seems work.

what doing wrong? tip or advice? thank in advance.

i using apache mysql , php on winodws. , has same issue. have in update-script called ajax

  1. an update sql statement
  2. query db mysql
  3. try update record without changes, (i mean simple updating row same data)

then... got nothing updated because bug in ajax query call update statement in server-side script. work if before saving (updating) data make changes it.

i using replace statement instead of update.

i looked solution lot of time, much. , can't understand why happens, because when debug entire script own params right on server , works fine, when ajax replace.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -