Ajax + PHP协作错误

NOTE: UPDATE - Please Read

Please Read, updated code, much better:

Also, I added an ajax error function and it doesn't call an error, the first time I do it, but the next time it happens, an error occurs, and the third and fourth times, and so on.

I have some code that doesn't seem to be working, and the problem is probably located in the Ajax request or the PHP receiving function, and I don't know what the problem could be.

Here is the important code, ask for any other code that could also be of help to you.


Jquery Ajax request

    $(document).ready(function()

{

        $("#secretcoin").mouseover(function()

        {

        $.ajax(

        {

        type: "POST",

        url: "achievements.php",

        data: { Home_Coin_Locator: "Yes" },

        error: errorAlert

        });

        });

});


Receiving side, PHP, which takes this info and stores it in a database:

$achieve4 = $_POST["Home_Coin_Locator"];

$astrSQL = "SELECT * FROM Awards_Inv WHERE Username = '$username'"; 

$rs3 = mysql_query($astrSQL, $connection); 


if ($achieve4 == "Yes")

{

while($row3 = mysql_fetch_array($rs3)){ 

$soar4 = $row3["Home_Coin_Locator"]; 

if ($soar4 == "Yes") 

{ 

$soa4 = "Yes"; 

} 

else 

{ 

$soa4 = "No";  

$awardSTRsql = "UPDATE Awards_Inv SET 'Home_Coin_Locator' = 'Yes' WHERE Username = '$username'";

mysql_query($awardSTRsql, $connection) or die(mysql_error()); 

$updatestatsSTRsql = "UPDATE User_Info SET `Coins` = Coins + 120, `Skill Points` = Skill Points + 10, `Awards` = Awards + 1 WHERE Username = '$username'"; 

mysql_query($updatestatsSTRsql, $connection) or die(mysql_error()); 

}

}

}

else

{

}

Ok, so my code might be weird, but just try to read it and see what the problem is.

I guess any other advice is also accepted, thanks for looking, and I hope you find something!

I added an error callback function and combined 3 mysql queries into 1, but the problem still exists.

Finally, read this code for info about the $connection and $username variables

$connection = mysql_connect("mysql1.000webhost.com", "username hidden", "password hidden") or die (mysql_error ());

mysql_select_db("a7347456_usersdb") or die(mysql_error());

session_start();

$username = $_SESSION["Username"];

Another factoid:

The error is that the info does not get updated to database, as far as I know.

first thing, make sure that you required the config file witch identify the $connection variable. and it will be easier if you describe what the problem exactly is.