473,408 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Google Map PHP / XML problem

Hi,

I'm having a couple of (possibly related) problems.

1) When I run this code as-is, I get an extra output to the screen...usually three numbers such as "559" or "205". The output appears in the HTML exactly where I've included "phpsqlajax_genxml.php" so that appears to the culprit.

I have checked both "phpsqlajax_genxml.php" and "phpsqlajax_expectedoutput.xml" (doing multiple searches) and there's nothing in there like the unwanted output that appears. Where are these numbers coming from?


2) In the phpsqlajax_genxml.php code if I uncomment the header() function I receive: "Warning: Cannot modify header information - headers already sent by..."

It seems that the header function is attempting to modify something other than the newly created XML file? How do I correct this so that the header function is only attempting to modify the "phpsqlajax_expectedoutput.xml" file.

Thanks!

Here's the code for phpsqlajax_genxml.php:

Expand|Select|Wrap|Line Numbers
  1. <?php require("phpsqlajax_dbinfo.php");
  2.  
  3. // Start XML file, create parent node
  4.  
  5. $dom = new DOMDocument("1.0");
  6. $node = $dom->createElement("markers");
  7. $parnode = $dom->appendChild($node); 
  8.  
  9. // Opens a connection to a MySQL server
  10.  
  11. $connection=mysql_connect ($host, $username, $password);
  12. if (!$connection) {  die('Not connected : ' . mysql_error());} 
  13.  
  14. // Set the active MySQL database
  15.  
  16. $db_selected = mysql_select_db($database, $connection);
  17. if (!$db_selected) {
  18.   die ('Can\'t use db : ' . mysql_error());
  19.  
  20. // Use previous query
  21. $result = mysql_query($query);
  22. if (!$result) {
  23.   die('Invalid query: ' . mysql_error());
  24.  
  25. //header("Content-type: text/xml");
  26.  
  27. // Iterate through the rows, adding XML nodes for each
  28.  
  29. while ($row = @mysql_fetch_assoc($result)){  
  30.   // ADD TO XML DOCUMENT NODE
  31.   $node = $dom->createElement("marker");
  32.   $newnode = $parnode->appendChild($node);
  33.   $newnode->setAttribute("name",$row['name']);
  34.   $newnode->setAttribute("address1", $row['address1']);
  35.   $newnode->setAttribute("address2", $row['address2']);
  36.   $newnode->setAttribute("neighborhood", $row['neighborhood']);
  37.   $newnode->setAttribute("telephone", $row['telephone']);
  38.   $newnode->setAttribute("lat", $row['lat']);
  39.   $newnode->setAttribute("lng", $row['lng']);
  40.   if ($row['num_user_ratings'] == 0) {
  41.   } else {
  42.       $num_user_ratings = $row['num_user_ratings'];
  43.       $user_rating = $row['user_rating'];
  44.       $rating_score = $user_rating/$num_user_ratings;
  45.       $newnode->setAttribute("rating_score", $rating_score);
  46.   }
  47. }
  48.  
  49. echo $dom->save("phpsqlajax_expectedoutput.xml");?>
And here's the search.php that includes the above file (I've removed some elements for the sake of brevity):

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   //$query removed for brevity
  3.   $result = mysql_query($query) or die(mysql_error()); 
  4. ?>
  5.  
  6.   </div>
  7.   <table border="0">
  8.   <tr>
  9.   <td valign="top">
  10.   <div id="resultsbox">
  11.   <table border="0">
  12.  
  13. <?php
  14.   while ($row = mysql_fetch_array($result)) {
  15.     // Several echos removed for brevity
  16.     echo "</TD></TR>";
  17.   }
  18.   //This is where the extra output ("559" or "205" etc.) appears.
  19.   include 'phpsqlajax_genxml.php';
  20. ?>
  21.  
  22.   </table>
  23.   </div>
  24.   </td>
  25.   <td valign="top">
  26.   <div id="map" class="map" style="width: 380px; height: 320px"></div></td>
  27.   </td>
  28.   </tr>
  29.   </table>
  30.  
  31. <?php
  32.   }
  33. ?>
  34.  
  35.   </div>
Nov 14 '08 #1
3 4043
pbmods
5,821 Expert 4TB
Heya, siikworm.

My guess is that the echo statement at the bottom of phpsqlajax_genxml.php is your culprit.

Try commenting it out.
Nov 16 '08 #2
Thanks! I can't believe I didn't notice that.

Any idea on the header() issue? The map seems to function perfectly well with the header function commented out, so maybe it's fine as is.
Nov 17 '08 #3
pbmods
5,821 Expert 4TB
In order to use the header() function, your script cannot have output anything before the header() call.

In the warning about "output already started", it should tell you where the output was started that prevented headers from getting sent. If you have any questions, post the error message you're getting, and we'll go from there.
Nov 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

29
by: Steve | last post by:
I have worked on a couple of sites which google's bot visits, partially lists and then goes away again. MSN and Yahoo are fine and working. Can anyone please suggest what, if anything, is...
32
by: sandy | last post by:
I have a hobby website at: http://www.montana-riverboats.com which also resolves as: http://montana-riverboats.com ...without the www. One address has a Google page rank of three. The other...
1
by: Xah Lee | last post by:
i have a problem i think only happens with OS X's Camino browser. (which is based on FireFox engine, but Fire Fox on OS X doesn't have this problem.) Basically, my website has javascript code...
17
by: MeerkatInFrance | last post by:
There comes a time when you know you are not going to be able to work something out yourself, however hard you try. I have reached that moment. I have a master page and a slave page (or whatever...
0
by: Andrew_Vodo | last post by:
Hi, I'm developning ASP.Net 2.0 application which will use Google Map. The page with Google Map uses master page. As Google map uses client-side script, the first problem is where do I have...
17
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post by:
Hello, I have build a website with approximately 30 html-pages. When I search this website in Google, I see the index.html or home.html on this website, but also other html-pages on this...
14
victorduwon
by: victorduwon | last post by:
Hi guys and gals, I am using javascript to autologin to my google analytics account via a hyperlink. This is what the text looks like this <?xml version="1.0" encoding="utf-8"?>...
10
by: Steve | last post by:
Just a warning to the group. The Google Toolbar causes Firebug to issue lots of "Too much recursion" errors in the toolbar.js and eventual causes my Firefox browser to stop responding when using...
15
by: maya | last post by:
hi, this site, http://www.mta.info/lirr/ has a "google translate" widget (on left column); when you click on drop-down some languages don't display properly (encoding problem), this problem...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.