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....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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". |