Mysqli sprintf查询更新无效

时间:2016-06-16 12:28:26

标签: php mysql mysqli

当用户离开我的网站时,我正在打开ajax脚本:

$(window).on('beforeunload', function()
{
    var formdataX = new FormData();
    formdataX.append("ip",ip);
    formdataX.append("source",source);
    formdataX.append("partner",partner);
    formdataX.append("stats_id",stats_id);
    formdataX.append("time",czas);
    formdataX.append("scroll",scrollmax);
    formdataX.append("help",help);
    formdataX.append("dema",dema);
    formdataX.append("beforeafter",beforeafter);
    formdataX.append("play1",play1);
    formdataX.append("play2",play2);
    formdataX.append("play3",play3);
    formdataX.append("play4",play4);
    formdataX.append("play5",play5);
    formdataX.append("after1",after1);
    formdataX.append("after2",after2);
    formdataX.append("after3",after3);
    formdataX.append("after4",after4);
    formdataX.append("after5",after5);
    formdataX.append("kuppan",kuppan);
    formdataX.append("adam",adam);
    formdataX.append("ableton",ableton);
    formdataX.append("roland",roland);
    formdataX.append("waves",waves);
    formdataX.append("slate",slate);
    formdataX.append("api",api);
    formdataX.append("sennheiser",sennheiser);
    formdataX.append("izotope",izotope);
    formdataX.append("pasekmail",pasekmail);
    formdataX.append("pasekporadnik",pasekporadnik);
    formdataX.append("pasekfacebook",pasekfacebook);
    formdataX.append("emailgit",emailgit);
    formdataX.append("orderwanted",orderwanted);
    formdataX.append("height",height);
    formdataX.append("width",width);
    formdataX.append("waluta",waluta);
    formdataX.append("lang",language);
    var ajaxX = new XMLHttpRequest();
    ajaxX.open("POST", "../php/stats.php");
    ajaxX.send(formdataX);
    return 'Did you read all my offer?';
});

这是我的stats.php:

try
    {
        if (! @include_once('connect.php'))
        throw new Exception ('connect.php not exist</br>');
        if (!file_exists('connect.php' ))
        throw new Exception ('connect.php not exist</br>');
        else
        require_once('connect.php'); 
    }
    catch(Exception $e)
    {    
        echo "You can not connect to the database.";
    }
    require_once "connect.php";
    $polaczenie = new mysqli($host, $db_user, $db_password, $db_name);
    $polaczenie->set_charset("utf8");

    function antyhakier($var)
    {
        $var = htmlentities($var, ENT_QUOTES, "UTF-8");
        $var = mysqli_real_escape_string($GLOBALS['polaczenie'], $var);
        return $var;
    }

    $ip = antyhakier($_POST['ip']);
    $source = antyhakier($_POST['source']);
    $partner = antyhakier($_POST['partner']);
    $stats_id = antyhakier($_POST['stats_id']);
    $time = antyhakier($_POST['time']);
    $scroll = antyhakier($_POST['scroll']);
    $help = antyhakier($_POST['help']);
    $dema = antyhakier($_POST['dema']);
    $beforeafter = antyhakier($_POST['beforeafter']);
    $play1 = antyhakier($_POST['play1']);
    $play2 = antyhakier($_POST['play2']);
    $play3 = antyhakier($_POST['play3']);
    $play4 = antyhakier($_POST['play4']);
    $play5 = antyhakier($_POST['play5']);
    $after1 = antyhakier($_POST['after1']);
    $after2 = antyhakier($_POST['after2']);
    $after3 = antyhakier($_POST['after3']);
    $after4 = antyhakier($_POST['after4']);
    $after5 = antyhakier($_POST['after5']);
    $kuppan = antyhakier($_POST['kuppan']);
    $adam = antyhakier($_POST['adam']);
    $ableton = antyhakier($_POST['ableton']);
    $roland = antyhakier($_POST['roland']);
    $waves = antyhakier($_POST['waves']);
    $slate = antyhakier($_POST['slate']);
    $api = antyhakier($_POST['api']);
    $sennheiser = antyhakier($_POST['sennheiser']);
    $izotope = antyhakier($_POST['izotope']);
    $pasekmail = antyhakier($_POST['pasekmail']);
    $pasekporadnik = antyhakier($_POST['pasekporadnik']);
    $pasekfacebook = antyhakier($_POST['pasekfacebook']);
    $emailgit = antyhakier($_POST['emailgit']);
    $orderwanted = antyhakier($_POST['orderwanted']);
    $height = antyhakier($_POST['height']);
    $width = antyhakier($_POST['width']);
    $lang = antyhakier($_POST['lang']);
    $waluta = antyhakier($_POST['waluta']);
    mysqli_debug("d:t:o,/mysqlbugs/client.trace");
    $polaczenie->query(sprintf("UPDATE `stats` SET `source`=%d, `time`=%d, `scroll`=%d, `help`=%d, `dema`=%d, `beforeafter`=%d, `play1`=%d, `play2`=%d, `play3`=%d, `play4`=%d, `play5`=%d, `after1`=%d, `after2`=%d, `after3`=%d, `after4`=%d, `after5`=%d, `kuppan`=%d, `adam`=%d, `ableton`=%d, `roland`=%d, `waves`=%d, `slate`=%d, `api`=%d, `sennheiser`=%d, `izotope`=%d, `pasekmail`=%d, `pasekporadnik`=%d, `asekfacebook`=%d, `emailgit`=%d, `orderwanted`=%d, `height`=%d, `width`=%d, `lang`='%s', `waluta`='%s', `polecacz`=%d WHERE `id`=%d", $source, $time, $scroll, $help, $dema, $beforeafter, $play1, $play2, $play3, $play4, $play5, $after1, $after2, $after3, $after4, $after5, $kuppan, $adam, $ableton, $roland, $waves, $slate, $api, $sennheiser, $izotope, $pasekmail, $pasekporadnik, $pasekfacebook, $emailgit, $orderwanted, $height, $width, $lang, $waluta, $partner, $stats_id));
    $polaczenie->close();

当然在INSERT之前只有零,我在数据库中看到它正在工作所以请告诉我这里有什么不对吗?我认为UPDATE查询有些不好,但我不知道。

0 个答案:

没有答案