title: Using PHP/MySQL with Google Maps
body: <p><strong>Update 2</strong>: So I never have used the debug function in firebug, but I just looked at the script section and I get this, now I will try and figure this out.</p>
  
  <blockquote>
    <p>Failed to load source for:
    <a href="http://localhost/googleMap/phpsqlajax_genxml.php" rel="nofollow noreferrer">http://localhost/googleMap/phpsqlajax_genxml.php</a></p>
  </blockquote>
  
  <p>Hiya,</p>
  
  <p>I followed this tutorial below
  <a href="http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#outputxml" rel="nofollow noreferrer">http://code.google.com/apis/maps/articles/phpsqlajax_v3.html#outputxml</a></p>
  
  <p>I ran into trouble, near then end, I am hoping someone else here has
  got this working and can help me discover my problem. Simply there are 4
  steps to this tutorial</p>
  
  <ul>
  <li>Creating the Table</li>
  <li>Populating the Table</li>
  <li>Outputting XML with PHP</li>
  <li>Creating the Map</li>
  </ul>
  
  <p>I successfully have completed all the steps, however the outputted xml
  isn't read by the google map I created. The files are all on the same
  directory, and I didn't change any of the file names from the
  tutorial. The tutorial has a step to test if the php file called
  phpsqlajax_genxml.php is outputting the xml and I successfully tested
  it and it was.</p>
  
  <p>The problem is that the map isn't rendering the items I have in the
  database, that should be converted to xml for the map to read.</p>
  
  <p>Any help, or pointing me in the right direction would be much
  appreciated.</p>
  
  <p><strong>UPDATE 1</strong>: I realize I don't have any code to show here, there are just 3 files so I am not sure which will be of the best use. I Have a question that might help my issue though.</p>
  
  <p>In the xml output part of the tutorial I am asked too</p>
  
  <blockquote>
    <p>Call this PHP script from the browser
    to make sure it's producing valid XML.
    If you suspect there's a problem with
    connecting to your database, you may
    find it easier to debug if you remove
    the line in the file that sets the
    header to the text/xml content type,
    as that usually causes your browser to
    try to parse XML and may make it
    difficult to see your debugging
    messages.</p>
  </blockquote>
  
  <p>This is the phpsqlajax_dbinfo.php file</p>
  
  <pre><code>&lt;?php
  $username="root";
  $password="root";
  $database="root-googleMap";
  ?&gt;
  </code></pre>
  
  <p>This is the code for the generate xml, Is a xml document actually made after and can I open in, or is it temporary conversion. If so How do i do the step above to test, I dont really understand.</p>
  
  <pre><code>&lt;?php
  require("phpsqlajax_dbinfo.php");
  
  // Start XML file, create parent node
  $doc = domxml_new_doc("1.0");
  $node = $doc-&gt;create_element("markers");
  $parnode = $doc-&gt;append_child($node);
  
  // 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());
  }
  
  // Select all the rows in the markers table
  $query = "SELECT * FROM markers WHERE 1";
  $result = mysql_query($query);
  if (!$result) {
    die('Invalid query: ' . mysql_error());
  }
  
  header("Content-type: text/xml");
  
  // Iterate through the rows, adding XML nodes for each
  while ($row = @mysql_fetch_assoc($result)){
    // ADD TO XML DOCUMENT NODE
    $node = $doc-&gt;create_element("marker");
    $newnode = $parnode-&gt;append_child($node);
  
    $newnode-&gt;set_attribute("name", $row['name']);
    $newnode-&gt;set_attribute("address", $row['address']);
    $newnode-&gt;set_attribute("lat", $row['lat']);
    $newnode-&gt;set_attribute("lng", $row['lng']);
    $newnode-&gt;set_attribute("type", $row['type']);
  }
  
  $xmlfile = $doc-&gt;dump_mem();
  echo $xmlfile;
  
  ?&gt;
  </code></pre>