This is my index page for my 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 get your 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 is my 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=? where username = asd";
$q = $conn->prepare($sql);
$q->execute(array($x),($y));
?>
This is my config.php page
<?php
$dbtype = "";
$dbhost = "localhost";
$dbname = "test";
$dbuser = "root";
$dbpass = "";
?>
The problem is when i am on my xampp testing my geo location out i keep getting a error Warning: PDOStatement::execute() expects at most 1 parameter, 2 given in C:\xampp\htdocs\project_track\myURL\location.php on line 15
I am trying to make a app that tracks my location and upload it to my database i been working on this project for some time hopefully i am on the right track i would like to know what do i do to correct this problem can some one please help...how should i set my database up for this i would like my app to record a username and lat and long and save it to my database and retrieve it so i can use it for google maps please help me with this...
Is my Sql wrong