Wednesday 23 January 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...