What i am trying to do is to create a marker on a map and to save it's data on a table on mysql database. I have already red some answers but i didn't find solution. The problem is that i recieve a message "page not found ".
The part to create the marker works. Here is my code:
<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapProp = {
center:new google.maps.LatLng(39.150005, 24.112234),
zoom:7,
mapTypeId:google.maps.MapTypeId.HYBRID
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var latit = <?php echo json_encode($_POST["latitude"]); ?>;
var long = <?php echo json_encode($_POST["longitude"]); ?>;
var marker=new google.maps.Marker({
position:new google.maps.LatLng(latit, long),
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:100%;height:1000px;"></div>
<button onclick="myFunction()">Drawing</button>
<p></p>
<script>
function myFunction() {
var myWindow = window.open("http://notamsforflights.eu/drawing/", "circle", "width=500, height=500");
}
</script>
</body>
</html>
Here is the link i followed to connect to my database but i get the message "page not found" and nothing happens in my table.
https://developers.google.com/maps/articles/phpsqlajax_v3
And here is my code:
<?php
/* a seperate file with my database info */
require("phpsqlinfo.php");
// Gets data from user's entry
$name = $_POST['name'];
$lat = $_POST['latitude'];
$lng = $_POST['longitude'];
$type = $_POST['type'];
// Opens a connection to a MySQL server
$connection=mysql_connect ("localhost", $username, $password);
if (!$connection) {
die('Not connected : ' . mysql_error());
}
// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Insert new row with user data
$query = sprintf("INSERT INTO markers " .
" (id, name, latitude, longitude, type ) " .
" VALUES (NULL, '%s', '%s', '%s', '%s', '%s');",
mysql_real_escape_string($name),
mysql_real_escape_string($lat),
mysql_real_escape_string($lng),
mysql_real_escape_string($type));
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
I checked the info of my database and they are correct. For your information i use wordpress for my site.
I would appreciate any help!