jquery - Keep getting error Warning: PDOStatement::execute() expects at most 1 parameter, 2 given in config.php line 15 -


this index page geo location page

<!doctype html> <html> <head> <script src="js/jquery.js"></script> </head>  <body> <script> setinterval ( "onpositionupdate()", 10000 );  var currposition; navigator.geolocation.getcurrentposition(function(position) {     updateposition(position);     setinterval(function(){         var lat = currposition.coords.latitude;         var lng = currposition.coords.longitude;         $.ajax({             type: "post",              url:  "myurl/location.php",              data: 'x='+lat+'&y='+lng,              cache: false         });     }, 2000); }, errorcallback);   var watchid = navigator.geolocation.watchposition(function(position) {     updateposition(position); });  function updateposition( position ){     currposition = position; }  function errorcallback(error) {     var msg = "can't location. error = ";     if (error.code == 1)         msg += "permission_denied";     else if (error.code == 2)         msg += "position_unavailable";     else if (error.code == 3)         msg += "timeout";     msg += ", msg = "+error.message;      alert(msg); } </script> </body> </html> 

this location.php page

<?php   include ('config.php');    // database connection   $conn = new pdo("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass);    // new data    $x = @$_post['x'];   $y = @$_post['y'];    // query   $sql = "update locations set x=?, y=? username = asd";   $q = $conn->prepare($sql);   $q->execute(array($x),($y));  ?> 

this config.php page

<?php $dbtype     = ""; $dbhost     = "localhost"; $dbname     = "test"; $dbuser     = "root"; $dbpass     = "";  ?> 

the problem when on xampp testing geo location out keep getting error warning: pdostatement::execute() expects @ 1 parameter, 2 given in c:\xampp\htdocs\project_track\myurl\location.php on line 15

i trying make app tracks location , upload database been working on project time on right track know do correct problem can 1 please help...how should set database app record username , lat , long , save database , retrieve can use google maps please me this...

is sql wrong

your execute line should be:

$q->execute(array($x, $y)); 

isn't ? input parameter should in form of array, supplied 2 parameters, 1 array, other 1 variable.

also, sql incorrect. should be:

update locations set x=?, y=? username = 'asd' 

reference: http://php.net/manual/en/pdostatement.execute.php


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -