PHP in XML File

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adamjblakey
    New Member
    • Jan 2008
    • 133

    PHP in XML File

    Hi,

    I have a script below which has been working fine however i have just moved server and rather than showing the page, it now just downloads it. Any ideas? The page is called sitempa.xml and the script is below. My thoughts is that the new server does not support something but not sure what to ask them to activate.

    Code:
    <?php
    
    // include init which contains all the includes.
    include('init.php');
    
    function stripres($value){
       
       $value = strtr($value, "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ. ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz--");
       $value = ereg_replace('[^a-zA-Z0-9_-]', '', $value);
       
       return $value;
       
    }
    
    header('Content-Type: application/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";
    ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <?php
    	$result = mysql_query("SELECT * FROM `pages` WHERE memberid = '$resv[id]' AND page_link = ''");
    	while ($row = mysql_fetch_assoc($result)) {
    ?>
    <url>
    <?php
    	if ($row['page_name'] == 'Home Page'){
    ?>
        <loc>http://<?php print $_SERVER['HTTP_HOST']; ?></loc>
    <?php }else{ ?>
    <loc>http://<?php print $_SERVER['HTTP_HOST']."/".$row['page_url'].".html"; ?></loc>
    <?php } ?>
        <lastmod><?php print $row['sdate']; ?></lastmod>
        <changefreq>daily</changefreq>
        <priority>0.5</priority>
    </url>
    <?php } ?>
    </urlset>
  • koharu
    New Member
    • Apr 2014
    • 10

    #2
    Verify that your Apache or webserver is configured to run XML files (if not just this XML file) as a PHP file, otherwise, calling it whatever.xml will cause the server to serve the php file as an XML file without the file being sent through the PHP Parser.

    Comment

    Working...