I am trying to connect each user's map to MySQL table titled "markers" so they can add a row by right clicking on the map, editing the info, and saving it. I am having difficulty with this. I don't quite understand how to connect the two, or where to place the php code.
My php code to connect the MySQL (in the phpsqlinfo_dbinfo.php is my username, password, database:
<?php
require("phpsqlinfo_dbinfo.php");
// Gets data from URL parameters
$title = $_GET['title'];
$arrival = $_GET['arrival'];
$departure = $_GET['departure'];
$description = $_GET['description'];
$lat = $_GET['lat'];
$lng = $_GET['lng'];
// 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, title, arrival, departure, description, lat, lng ) " .
" VALUES (NULL, '%s', '%s', '%s', '%s', '%s');",
mysql_real_escape_string($title),
mysql_real_escape_string($arrival),
mysql_real_escape_string($departure),
mysql_real_escape_string($description),
mysql_real_escape_string($lat),
mysql_real_escape_string($lng));
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
?>
Each user will have a map similar to this: http://www.tothenationsworldwide.com/social-travel-map/
I want each user to be able to add a marker (right click) and save the information into the MySQL.
Can somebody help me with this? I have been attempting this for too long. I believe my coding is correct. My Javascript is definitely correct for my map to work.
Thanks for any help you can provide!
Mike.