Hi I want to update some data in my mysql database by using form in html and AJAX technology. I have problem because data is not updated after click on submit and in response message I have not only message but clear mysql ask too! Let's look at my alert:
My idea is the printf is not really post text into "query" function but this text output is going stright into response data and query is always wrong from empty text...
Let's look at my AJAX php file:
<?php
session_start();
error_reporting(0);
$imie = $_POST['imie'];
$nazwisko = $_POST['nazwisko'];
$kodpocztowy = $_POST['kodpocztowy'];
$ulica = $_POST['ulica'];
$nrdomu = $_POST['nrdomu'];
$nrmieszkania = $_POST['nrmieszkania'];
$miasto = $_POST['miasto'];
try
{
if (! @include_once('connect.php'))
throw new Exception ('connect.php kurwa nie istnieje</br>');
if (!file_exists('connect.php' ))
throw new Exception ('connect.php nie istnieje</br>');
else
require_once('connect.php');
}
catch(Exception $e)
{
echo "Wiadomość: " . $e->getMessage();
echo "Kod: " . $e->getCode();
}
require_once "connect.php";
$polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
if($rezultat = @$polaczenie->query(printf("UPDATE adresy SET imie='%s', nazwisko='%s', kodpocztowy='%s', ulica='%s', nrdomu='%s', nrmieszkania='%s', miasto='%s' WHERE id=%s",$imie,$nazwisko,$kodpocztowy,$ulica,$nrdomu,$nrmieszkania,$miasto,$_SESSION['id'])))
{
$polaczenie->close();
echo "Good!";
}
else
{
$polaczenie->close();
echo "Not good!";
}
?>
Have you any idea how to solve this problem? Maybe what to use instead printf or echo? Please help, greatings.