Wednesday, January 23, 2019

javascript - How do I determine if my ajax request is failing on the client side or server side?

I'm trying to click a picture and change a database value to "0" via an onclick Javascript function. I looked at a few examples but I can't seem to make it work.



How can you use php in a javascript function



How to update data using onclick even CHECKBOX without button submit in php and mysql



Update Database from Javascript onClick By Ajax PHP




This is the index.html file









This is the update.php file.



$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "dbname";



$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$num = $_POST["num"];
$id = 1;

$sql2 = "UPDATE db SET Column1='$num' WHERE id='$id'";

if ($conn->query($sql2) === TRUE) {
echo "Updated";
} else {
echo "Failed";
}


Would someone please point out what I'm doing wrong?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...