Zariweya Zariweya - 2 months ago 17
MySQL Question

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

After following several examples from this website I think I'm about to do it but still can't.

I have this code:


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


function update_it(n_id){
type: 'POST',
url: 'update_yes.php',
data: {idd: n_id},
success: function(output)
alert('Updated, server says '+n_id);
}, error: function()


$link = mysqli_connect("localhost", "root", "****", "****");
$sql = "DELETE FROM stuff WHERE id = " .$_POST["idd"];
mysqli_query($link,$sql) or die(mysql_error());

And everything works but the PHP (I think). I say this because I can see how the HTML works properly and how the AJAX function return the success message, but still nothing happens in the database.

I tried different structures in the data field of the AJAX function like
data: 'idd': n_id,
data: 'idd=' n_id,
but nothing seems to work.

What am I doing wrong? Any tip or advice? Thank you in advance.


Ok, finally I found a solution.

The code is pretty find, it is an apache ownerships and rights problem.

This helped a lot.

Thank you guys for all you comments.