but when i open that .xml file in safari nothing appeared. I listened in google that i must turn on parser, something like this in .htaccess :
PHP Code:
AddType application/x-httpd-php .php .xml
but when i add this string to htaccess and then open my site, ordinary page and a my xml rss file, but they just was download, when i open they. I don't know how to make my php code work in that xml file. Please help me. Thanks.
Do you see anything in the browser if you do a "View source" on the resulting page?
PS: Shouldn't your output start with an <?xml... tag?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
yes i see a xml page without any php code, there is no any code that in <?php ?>
That's a good thing. It means the PHP was successfully processed on the server and output the XML text to your browser.
Seriously i don't know about it. I do it how it was in a lesson and it was like i show previously.
Try adding this:
PHP Code:
<?php header('Content-type: text/xml'); ?>
<?php
@include_once("./cfg.inc.php");
$link = mysql_connect($DBSERVER, $DBUSER, $DBPASS)
or die("Can't connect" );
mysql_select_db($DB, $link) or die ("Can't select DB");
echo "<?xml version='1.0' encoding='utf-8'?>"; // <<-------<<<<<<<
?>
<rss version="2.0">
<channel>
...etc....
(Echoing the xml tag within the PHP code can help avoid confusion by the PHP parser if you have PHP short tags enabled.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
That's a good thing. It means the PHP was successfully processed on the server and output the XML text to your browser.
I think that the php doesn't work at all in this file because i try to add something to xml output like $test = "test"; and then echo this in <description> tags but nothing was appeared
i make like this but the ?> in this string: echo "<?xml version='1.0' encoding='utf-8'?>";
is recognized like a php close tag, i think it's because xml file, i try to put in just in the start of file (because if not the error appeared, that told this string must be in start of file) but after that nothing change.
may be i wrong and the rss feed had a xml markup but the .php file??
i talk with my hosting support they told me that all checked up and all ok.
I think that the php doesn't work at all in this file because i try to add something to xml output like $test = "test"; and then echo this in <description> tags but nothing was appeared
i make like this but the ?> in this string: echo "<?xml version='1.0' encoding='utf-8'?>";
is recognized like a php close tag, i think it's because xml file, i try to put in just in the start of file (because if not the error appeared, that told this string must be in start of file) but after that nothing change.
may be i wrong and the rss feed had a xml markup but the .php file??
i talk with my hosting support they told me that all checked up and all ok.
Can you more descriptive with "but nothing was appeared"? Are you viewing the source in a browser? Are you using an RSS reader?
When I last had a rss generator I used PHP to write the rss file;
PHP Code:
$fp = fopen($xmlFile, "w"); // make a new RSS file each time. fwrite($fp, $rss_header); fwrite($fp,$rssContent); fwrite($fp, $rss_footer); fclose($fp);
I'm using a Safari browser, it has a rss reader, so i use it. When i open xml file with that code that i mentioned previously, i see a rss feed but it contain only that was in a xml markup, nothing about php code, like it isn't in that file at all. How can i make that php code carried???
I'm using a Safari browser, it has a rss reader, so i use it. When i open xml file with that code that i mentioned previously, i see a rss feed but it contain only that was in a xml markup, nothing about php code, like it isn't in that file at all. How can i make that php code carried???
It looks like you are missing all your "echo" statements:
What environment are you doing this testing in? PHP and MySQL must be run from a server, such as apache or IIS.
Generally speaking to create an rss feed you would create a file named rss.xml to do that you need to write the file out to the server. If you are just looking at what you think your browser will do with an rss feed, may not be correct if the rss feed is not really a rss feed. A php file must have a .php file extension, and an rss feed needs to be a .xml.
i think i found a solution for my problem, i must use PHP to process XML files, i need do it somehow in the htaccess. Can someone tell some rules for this?
i think i found a solution for my problem, i must use PHP to process XML files, i need do it somehow in the htaccess. Can someone tell some rules for this?
Usually I point to a PHP file directly rather than to get the engine to process all xml files. ie: rss.php instead of rss.xml.
What environment are you doing this testing in? PHP and MySQL must be run from a server, such as apache or IIS.
Generally speaking to create an rss feed you would create a file named rss.xml to do that you need to write the file out to the server. If you are just looking at what you think your browser will do with an rss feed, may not be correct if the rss feed is not really a rss feed. A php file must have a .php file extension, and an rss feed needs to be a .xml.
English is not my native language, and if i clear understood what you told, i'm doing right. OK how i did my rss file: I made a file rss.xml, then i paste this
Bookmarks