php not outputting xml

This is a discussion on php not outputting xml within the PHP Language forums, part of the PHP Programming Forums category; Hello I am having a problem getting some php to output some xml. I'm using this tutorial: http://code....


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-21-2008
LAN MIND
 
Posts: n/a
Default php not outputting xml

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

http://code.google.com/support/bin/a...y?answer=65622

Here is my the html page:

http://lanmind01.googlepages.com/new.html

and the php:

http://lanmind01.googlepages.com/phpsqlajax_genxml.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
so:

<?php
require("phpsqlajax_dbinfo.php");
// 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)){
// ADD TO XML DOCUMENT NODE
$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:

<?
$username="root";
$password="";
$database="root-markers2";
?>

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
Reply With Quote
  #2 (permalink)  
Old 02-21-2008
Dikkie Dik
 
Posts: n/a
Default Re: php not outputting xml

> Here is what that file looks like:
>
> <?
> $username="root";
> $password="";
> $database="root-markers2";
> ?>



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

<?php

and see what happens.
Reply With Quote
  #3 (permalink)  
Old 02-21-2008
LAN MIND
 
Posts: n/a
Default Re: php not outputting xml

On Feb 21, 2:21 pm, Dikkie Dik <dik...@nospam.org> wrote:
> > Here is what that file looks like:

>
> > <?
> > $username="root";
> > $password="";
> > $database="root-markers2";
> > ?>

>
> It may just be that short tags are off on your server. Start that file with:
>
> <?php
>
> and see what happens.


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".
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0