473,786 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to stop PHP from generating blank line for first character of XML?

2 New Member
My PHP code is generating XML with a blank first line before the <?xml version="1.0" ?>

see http://urbanbees.co.uk/maps/phpsqlajax_genxml3.php

I have been told this is the reason why my map is not showing the markers in chrome and FF but it is OK in IE8. see http://urbanbees.co.uk/maps/map_of_h...ons_update.htm You'll either see markers or not depending on your broswer.

How do I change the code to not generate this first blank line.

Here is the php code.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require("phpsqlajax_dbinfo.php");
  3. // Start XML file, create parent node
  4. $dom = new DOMDocument("1.0");
  5. $node = $dom->createElement("markers");
  6. $parnode = $dom->appendChild($node);
  7. // Opens a connection to a MySQL server
  8. $connection=mysql_connect (localhost, $username, $password);
  9. if (!$connection) {  die('Not connected : ' . mysql_error());}
  10. // Set the active MySQL database
  11. $db_selected = mysql_select_db($database, $connection);
  12. if (!$db_selected) {
  13.   die ('Can\'t use db : ' . mysql_error());
  14. }
  15. // Select all the rows in the markers table 
  16. $query = "SELECT * FROM markers WHERE 1"; 
  17. $result = mysql_query($query); 
  18. if (!$result) {   
  19.   die('Invalid query: ' . mysql_error()); 
  20. }  
  21. header("Content-type: text/xml");  
  22. // Iterate through the rows, adding XML nodes for each 
  23. while ($row = @mysql_fetch_assoc($result)){   
  24.   // ADD TO XML DOCUMENT NODE   
  25.   $node = $dom->createElement("marker");   
  26.   $newnode = $parnode->appendChild($node);    
  27.   $newnode->setAttribute("name",$row['name']); 
  28.   $newnode->setAttribute("address", $row['address']);   
  29.   $newnode->setAttribute("lat", $row['lat']);   
  30.   $newnode->setAttribute("lng", $row['lng']);   
  31.   $newnode->setAttribute("type", $row['type']); 
  32. }  
  33. echo $dom->saveXML();
  34. ?>
Feb 9 '11 #1
1 7156
brian mccallum
2 New Member
I have found the problem. There was a space after the end of the php code in 'phpsqlajax_dbi nfo.php' which was called from the above code. Taking away the space after the ?> solved the issue.
Feb 9 '11 #2

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

Similar topics

2
1986
by: Gary | last post by:
Morning all, I have a form field called: Bsk01 How do I onBlur prompt the user to enter a ZERO as character one, if one is not already entered. At the same time, I would like to ensure at least 5t characters have been entered. This validation should also only trigger if anything is entered. Basically, if the user chooses to enter nothing then the check should not be carried out and the user should be able to continue.
8
7640
by: Mr. B | last post by:
In VB6, I had some code which 'forced' the first character of a string entered to be Capital. For example, if a person was entering their name (john doe)... the code would 'force' --- John Doe. Here is what I believe is the VB6 code: Private Sub txbModUser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txbModUser.TextChanged KeyAscii = AutoType(Screen.ActiveControl, KeyAscii) End Sub
2
1451
by: Greg Buckley | last post by:
I have come across an interesting problem. Let me first state that I am not a fluent ASP programmer. I am a network engineering trying to port an existing app. The app in question is currently running on IIS 5.0 (2Kserver) in a NT 4.0 domain. I am moving it to an IIS 6.0 server in a 2003 Active Directory domain. My app calls this variable <%= varUser %> and brings the users login name to the web page as well as using it to pull data...
1
1161
by: asnowfall | last post by:
IE throws error at <1060> for this XML file ------------------------------------------ <?xml version="1.0"?> <root> <1060> <UUID> 1bac9070-bf3b-404f-b7ca-ada24fc09eb3 </UUID> </1060> </root>
2
2075
by: D.Frangiskatos | last post by:
Hi, I have been working for a few months in project that deals raw sockets. However recently, and while trying to examine the contents of the buffer used in recvfrom i was a bit confused. The buffer was allocated using malloc as it can be seen next: do { ..............
0
1120
by: seanmayhew | last post by:
Im having a small problem with my Dataview sort. Its sorting correctly on the first character but after thats it seems random so for a state list at the "W's" it looks like this: WA WV WY WI Any help greatly appreciated.
9
7993
by: sovht | last post by:
System: Intel, Windows XP Pro, SP2 IDE: VC++ 6.0 Problem: *Very* simple program to create a MessageBox only ever displays the first character of the given string. I checked the spec for the MessageBox function and I believe I am adhering to it. I have also done a search for this issue, but have come up empty handed. Perhaps my search parameters were at fault ... #include <windows.h> // added to make MessageBox work (esp w/MB_<code>s)...
4
1589
by: cyberlei | last post by:
like user have to type "A" for the first character in the blank bar,so how can i restrict the "A" for the first character in php string? Thank you
4
13001
by: JHite | last post by:
I'm using AC2003. Sequence of events: a. Tool -> Relationships I show my tables & relationships and arrange them to fit landscape mode. b. File ->Print Relationships This generates a report in portrait mode with name/date etc. in report header section, an empty page header section, and diagram of relationships in detail section. c. I go into setup, change to landscape orientation and adjust margins so my "print" is not too...
4
15381
by: Divyanshi | last post by:
Hello all, I have a textbox, in which i have to perform the following validations 1)first character cannot be blank space 2)characters should not exceed 100 3)if exceeded 100, it should trim the i/p to 100 characters How can i do it? Please give your valuable suggestions
0
9650
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6748
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.