Autor | Zpráva | ||
---|---|---|---|
deliQus Profil |
#1 · Zasláno: 1. 1. 2010, 19:38:29 · Upravil/a: deliQus
Mám tento php skript na generovaní rss kanálu:
<?php require_once("config.php"); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Type: text/xml; charset=utf-8'); ?> <xml version="1.0" encoding="utf-8"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>web.com</title> <link>http://www.web.com/</link> <webMaster>ms@web.com (MS)</webMaster> <category>finance, spoření, spořící účty, termínované účty, stavební spoření, penziní připojištění</category> <docs>http://backend.userland.com/rss</docs> <lastBuildDate><?php echo gmdate("D, d M Y H:i:s")." GMT"; ?></lastBuildDate> <atom:link href="http://www.web.com/rss/" rel="self" type="application/rss+xml" /> <image> <url>http://www.web.com/graphics/mini_title.gif</url> <title>web.com</title> <link>http://www.web.com/</link> </image> <?php $res = mysql_query("SELECT * FROM `clanky` order by datum",$GLOBALS["link"]); while($rec = mysql_fetch_array($res)) { ?> <item> <title>Článek</title> <link>http://www.web.com/clanky&id=<?php echo $rec["id"]; ?>/</link> <guid>http://www.web.com/clanky&id<?php echo $rec["id"]; ?>/</guid> <description><?php echo htmlspecialchars(strip_tags($rec["nadpis"])); ?></description> <pubDate><?php echo $rec["datum"]; ?></pubDate> </item> <?php } ?> A hází mi to: Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/osporeni.com/osporeni.com/index.php:2) in /var/www/web5/osporeni.com/osporeni.com/rss.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/osporeni.com/osporeni.com/index.php:2) in /var/www/web5/osporeni.com/osporeni.com/rss.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/osporeni.com/osporeni.com/index.php:2) in /var/www/web5/osporeni.com/osporeni.com/rss.php on line 5 Nevíte čím by to mohlo být ? Respektive, jak to udělat správně. |
||
Alphard Profil |
#2 · Zasláno: 1. 1. 2010, 19:51:47
Jestli máte zapnuté short_open_tags, tak je problém v <?xml. Řešení najdete v FAQ.
|
||
GeneralDv Profil |
#3 · Zasláno: 1. 1. 2010, 19:52:12 · Upravil/a: GeneralDv
<?xml version="1.0" encoding="utf-8"?> Tagy pro PHP, viz http://diskuse.jakpsatweb.cz/?action=vthread&forum=9&topic=2111 //pozdě! |
||
fuckin Profil |
#4 · Zasláno: 1. 1. 2010, 19:55:29
Musíš si uvědomit že <?xml version="1.0" encoding="utf-8"?> tímto zapneš php jednoduše řečeno. Dále jsi tam měl další chybu, mas to tam zakomentované.
<?php require_once("config.php"); header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Content-Type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>web.com</title> <link>http://www.web.com/</link> <webMaster>ms@web.com (MS)</webMaster> <category>finance, spoření, spořící účty, termínované účty, stavební spoření, penziní připojištění</category> <docs>http://backend.userland.com/rss</docs> <lastBuildDate><?php echo gmdate("D, d M Y H:i:s")." GMT"; ?></lastBuildDate> <atom:link href="http://www.web.com/rss/" rel="self" type="application/rss+xml" /> <image> <url>http://www.web.com/graphics/mini_title.gif</url> <title>web.com</title> <link>http://www.web.com/</link> </image> <?php $sql = "SELECT * FROM `clanky` WHERE id='".$_GET['id']."'LIMIT 1"; //odebrano ,$GLOBALS["link"]; nechapu co to ma byt $res = mysql_query($sql); while($rec = mysql_fetch_array($res)) { ?> <item> <title>Článek</title> <link>http://www.web.com/clanky&id=<?php echo $rec["id"]; ?>/</link> <guid>http://www.web.com/clanky&id<?php echo $rec["id"]; ?>/</guid> <description><?php echo htmlspecialchars(strip_tags($rec["nadpis"])); ?>/description> <pubDate><?php echo $rec["datum"]; ?></pubDate> </item> <?php } ?> |
||
deliQus Profil |
#5 · Zasláno: 1. 1. 2010, 19:55:59
GeneralDv:
Jojo, to už jsem opravil :-) |
||
deliQus Profil |
#6 · Zasláno: 1. 1. 2010, 19:57:24 · Upravil/a: deliQus
Stále to hází:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/web.com/web.com/index.php:2) in /var/www/web5/web.com/web.com/rss.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/web.com/web.com/index.php:2) in /var/www/web5/web.com/web.com/rss.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at /var/www/web5/web.com/web.com/index.php:2) in /var/www/web5/web.com/web.com/rss.php on line 5 |
||
fuckin Profil |
#7 · Zasláno: 1. 1. 2010, 20:00:32
Citováno z FAQ na tomto serveru, stačí jen hledat :)
headers already sent... Pokud už byl generovaný nějaký výstup, tak už nelze používat funkce header(), setcookie() ani session_start(). Jejich volání skončí chybou. Přesvědčete se, že před začátkem <?php ?> není žádný text (ani mezera) a že nebylo nic odesláno třeba funkcemi jako echo nebo print. Pokud je text v UTF-8, tím výstupem může být i tzv. BOM signatura, vizte výše zmíněný Divný znak (čtvereček).... |
||
deliQus Profil |
#8 · Zasláno: 1. 1. 2010, 20:09:04
Teď mi to funguje jen když to zobrazím v indexu ( index.php?page=rss ) ale když dam normal web.com/rss.php tak to nejde a hází to:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'web_com'@'localhost' (using password: NO) in /var/www/web5/web.com/web.com/rss.php on line 20 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/web5/web.com/web.com/rss.php on line 20 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/web5/web.com/web.com/rss.php on line 21 |
||
Alphard Profil |
#9 · Zasláno: 1. 1. 2010, 20:13:07
Chyba s připojením, k databázi se připojujete v config.php?
|
||
deliQus Profil |
#10 · Zasláno: 1. 1. 2010, 20:13:48
Jojo, přes config.php
|
||
fuckin Profil |
#11 · Zasláno: 1. 1. 2010, 20:15:05 · Upravil/a: fuckin
Protože v indexu je evidentně navázáno připojení k databázi. Kdežto v rss.php nikoli. Z chybových hlášek lze vidět že nejste připojený k databázi.
Warning: mysql_query() [function.mysql-query]: Access denied for user 'web_com'@'localhost' (using password: NO) in /var/www/web5/web.com/web.com/rss.php on line 20 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /var/www/web5/web.com/web.com/rss.php on line 20 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/web5/web.com/web.com/rss.php on line 21 Nevymazals ten config.php z toho důvodu aby se tam neukazovalo to headers already sent ? |
||
deliQus Profil |
#12 · Zasláno: 1. 1. 2010, 20:16:25
Jojo, měl jsem tam chybu, už to jde, díky
|
||
Časová prodleva: 14 let
|
0