php not outputting xml

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello I am having a problem getting some php to output some xml. I'm
using this tutorial:

Here is my the html page:

and the php:

Now I know Google pages doesn't support php I only have my page here
so I can post links to it (I am working locally). I have the mysql
connection settings in a seperate file. Like I said I can't get the
php to output xml. In the tuitorial it gives 3 php codes to choose,
I've tried all 3 and they all just give php text as a response like

// Start XML file, create parent node
$doc = domxml_new_doc("1.0");
$node = $doc->create_element("markers");
$parnode = $doc->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)){
  $node = $doc->create_element("marker");
  $newnode = $parnode->append_child($node);
  $newnode->set_attribute("name", $row['name']);
  $newnode->set_attribute("address", $row['address']);
  $newnode->set_attribute("lat", $row['lat']);
  $newnode->set_attribute("lng", $row['lng']);
  $newnode->set_attribute("type", $row['type']);
$xmlfile = $doc->dump_mem();
echo $xmlfile;

I believe it might be caused by a few things. My connection settings:

Here is what that file looks like:


So this is how I have the connection settings entered. Obviously I've
removed my password. As for the database connection setting I have
entered my username followed by a "-" then the database name. I'm not
sue that all this is all correct syntax but I believe it is.

My server. I'm using WampServer to work locally. Everything from the
php (5.2.5), apache to the mysql is current. I even checked the
phpdom_xml extension for the php. I have all my files (html,php, &
mysql connection settings in a folder in the www directory. Mysql is
online as I've been creating db's & tables etc.

I've followed the tutorial mentioned to the T, I'm just really new to
databases and php in general. I've been grinding on this for 7 hrs now
and I'm just at a loss. Any help on something else to check or a
pointer is greatly appreciated. Thanks- Lan

Re: php not outputting xml

Quoted text here. Click to load it

It may just be that short tags are off on your server. Start that file with:


and see what happens.

Re: php not outputting xml

Quoted text here. Click to load it

Thanks Dikkie but it's still a no go though.... I went into the PHP
settings on WampServer's menu and checked "short open tag". I also did
like you said adding the "php".

Site Timeline