What am i doing wrong? create xml using php
I am following this tutorial step by step http://code.google.com/apis/maps/articles/phpsqlajax.html . Actually I copy pasted the code and created the database,开发者_开发知识库 added the data to the table, downloaded the provided php and html files but when i actually try to run the page that will create the xml file i get this error. Can anyone guess what is wrong? I am using XAMPP 1.7.4 [PHP: 5.3.5]
(The google tutorial suggests 3 ways to generate the xml file. I tried all 3 of them and the same error appears on the first 2 and an "error on line 10" (which is the line that php script begins) appears when i try the 3rd suggested way. I am thinking if this wont work to use mysqldump command in order to export the xml file i need.)
You have two root elements in your XHTML: html
and markers
. This is why your browser correctly considers it to be invalid.
The problem with blindly copying/pasting code is that when you come across a problem it's very difficult to solve, because you don't understand what the code is doing. I suggest you read through the code closely. When you understand it, you'll be able to fix it.
Essentially you'll want to remove all of the output up until the <markers>
tag. Perhaps the HTML file you're using is incorrect.
-EDIT-
Problem was in the connection to the database, value for $host and/or $user and/or $pass was incorrect or not provided.
If you use version 2 (phpsqlajax_genxml2), edit the file at line 15
replacing localhost
with 'localhost'
.
If you use version 3 (phpsqlajax_genxml3), edit the file at line 13
replacing localhost
with 'localhost'
.
Then try again.
精彩评论