I have an ajax call to a php script that goes into a database and updates a row of information. If I type the link into the browser with the supplied information I want to change then it works fine without an issue. I have SEVERAL ajax calls set up the same way as this one and they all work without a problem. Can’t figure out why this ajax call to the php script is failing to do anything.
javascript call:
function updateInfo(userID, email, username, password){
var validGT;
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4){
if (xmlHttp.status == 200){
validGT = xmlHttp.responseText;
if(validGT == "Success!"){
var error = document.getElementById("update-error-message");
error.innerHTML = "Updated!";
}else{
var error = document.getElementById("update-error-message");
error.style.color = "Red";
error.innerHTML = "error occured";
}
}
}
}
xmlHttp.open("GET", "updateInfo.php?userID=" + userID + "&email=" + email + "&gamertag=" + gamertag + "&password=" + password, true);
xmlHttp.send();
}
php script:
****connect to database and such****
$userID = $_GET{"userID"};
$email = $_GET{"email"};
$username = $_GET{"username"};
$password = $_GET{"password"};
if($password != "null"){
mysql_query("UPDATE users SET email='$email', username='$username', password='$password' WHERE uid='$userID'") or die(mysql_error());
echo "Success!";
}else{
mysql_query("UPDATE users SET email='$email' AND username='$username' WHERE uid='$userID'") or die(mysql_error());
echo "Success!";
}
mysql_close($con);
I get a response back from the ajax call saying “Success!” however it doesn’t actually do anything to the information in the database. I used firebug to make sure the information was being passed correctly and it is. So I am at loss here. What is up? Anyone have an idea?
this looks weird try
If that does not help, try to debug/echo the query to see whats happening
also change
to
but since you’ve never gotten any sql error, password seems to be “null” all the time