Je pige plus rien (sql et google map)

AsselusBorealiss Messages postés 79 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 24 septembre 2007 - 6 janv. 2007 à 02:18
AsselusBorealiss Messages postés 79 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 24 septembre 2007 - 7 janv. 2007 à 23:52
Bonjour a tous et bonne annee a tous (te)

une Demande d’explication SVP




Sur le lien suivant 

http://maps.forum.nu/gm_markers_from_db.php.txt







 ou l’exemple

http://maps.forum.nu/gm_markers_from_db.php
) la personne nous montre comment a partir d’une carte GOOGLE MAP enregistrer un point (marker) en cliquant sur la carte



Donc je test le code j’enregistre la page je la Download  sur mon accès  FREE




Je test cela .....marche après quelque modification je clic et hop un markers d'enregistrer ( 2 et 3 )et après je regarde dans ma base SQL et la il n’y a pas
De base de créer, et pourtant il y a bien des markers d’enregistrer sur ma page, donc je change le nom de la base
Idem la page enregistre bien des markers mais je ne les aperçois dans ma base …




Je voulais s’avoir si une personne pouvait me donne une explication
<?xml:namespace prefix o ns "urn:schemas-microsoft-com:office:office" /??>

 






Je colle le code que je test  (faire un copier dans une page.php avec une Google MAp  et l'autre dans un cfg.php)




--------------------------------------------------la page php --------------------------------------------------------------



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>--------------- test -------------------</title>
</head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=***************ma-cle****************"
      type="text/javascript"></script>
<?php




include("cfg.php");  // la page avec les ident free


// Make sure the table exists
assertTable();


// define vars
$desc = '';
$lat = '';
$lon = '';


// read POST variables if present
foreach ($_POST as $name => $value) {
 $$name = $value;
}




// If post variables desc,lat and long are not empty then we're inserting
if ($desc &&  $lat &&  $lon) {
 if (is_numeric($lat) && is_numeric($lon) && is_string($desc)) {


  if ($lat < -85 || $lat > 85 || $lon < -180 || $lon > 180) {
   print "You've entered invalid values";
   exit;
  }


  $desc = addslashes(substr($desc,0,200));
  $sql = "insert into france values ( null , $lat, $lon, '$desc' )";
  $result = mysql_query($sql,$base) or DBError("LINE: " .__LINE__. " $sql");
  print "Point inserted
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Google Maps JavaScript API - PHP/DB Example</title>


<script type="text/javascript">
var mArray = Array();
var map;
var centerPoint = new GLatLng(40.078071,-101.689453);
var minimap = new GOverviewMapControl(new GSize(250,150));


 


function load() {
 doLoad();
 $jsPointsArray
 addMarkers();
}


function doLoad() {
 if (GBrowserIsCompatible()) {
  map = new GMap2(document.getElementById("map"));
  map.setCenter(centerPoint, 0);
  map.addControl(new GScaleControl());


  map.enableContinuousZoom();
map.enableDoubleClickZoom();
  map.addControl(new GMapTypeControl());
  GEvent.addListener(map, 'click', mapClick);
  map.addControl(minimap);


 }
}


function addMarkers() {
 if (mArray.length) {
  var bounds = new GLatLngBounds();
  for (n=0 ; n < mArray.length ; n++ ) {
   var mData = mArray[n].split(';');
   var point = new GLatLng(mData[0],mData[1]);
   bounds.extend(point);
   var marker = createMarker(point, mData[2]);
   map.addOverlay(marker);
  }
  map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
 }
}


function createMarker(point, title) {
 var marker = new GMarker(point,{title:title});
 GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml('
' + title + '<hr>Lat: ' + point.y + '
Lon: ' + point.x + '
');
 });
 return marker;
}


function mapClick(marker, point) {
 if (!marker) {
  oLat = document.getElementById("lat");
  oLat.value = point.y;
  oLon = document.getElementById("lon");
  oLon.value = point.x;
  oDesc = document.getElementById("desc");
  oDesc.value = 'New point';




 }
}


 


</script>
</head>










<form method=\"POST\">
 ----

  Add a marker,
 
 ----

  Description,
  , Latitude, , Longitude, ,
 
 ----

  ,
 
 ----

  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 <?php
//CONNEXION AU SERVEUR


$serveur = 'sql.free.fr'; // Votre serveur. Ex : localhost.
$login = 'lelogindetabase'; // Votre Login de connexion à la base.
$pass = 'lepassworddetabase'; // Votre Password de connexion à la base.
$base = 'lenomdetabase'; // Le Nom de votre Base de Données.


$link = @MYSQL_CONNECT($serveur,$login,$pass) or die ("Le Serveur ne répond pas");
@MYSQL_SELECT_DB("$base",$link) or die ("Connexion à la base $base impossible");


?>
 

</html>

---------------------------------------------------------------------------------end code -------------------------------------------------------------

1 réponse

AsselusBorealiss Messages postés 79 Date d'inscription dimanche 15 octobre 2000 Statut Membre Dernière intervention 24 septembre 2007
7 janv. 2007 à 23:52
en faite dans le code il y a bien un creation de base :



function assertTable() {
 global $base;
 // Create table, if it does not already exist
 $createTableSQL = <<<EOS
 CREATE TABLE IF NOT EXISTS france (
   id int(11) NOT NULL auto_increment,
   lat decimal(12,8) NOT NULL,
   lon decimal(12,8) NOT NULL,
   description varchar(255) NOT NULL,
   PRIMARY KEY (id)
 ) TYPE=MyISAM;
EOS;



 $sql = $createTableSQL;
 $result = mysql_query($sql,$base) or DBError("LINE: " .__LINE__. " $sql");
}



et apparement meme si dans mon fichier cfg.php je lui dis que ma base est une autre base
et bien il continu a me stocker les infos dans la base du site
avec surement les lignes   $createTableSQL = <<<EOS

enfin je pense
0
Rejoignez-nous