我的HTML文件:首先HTML/PHP的形式是給我一個500服務器錯誤
<html>
<head><title>RSS Form</title></head>
<body>
<form method='post' action='write.php'>
<img src='logo.png' align='left' />
<font size='6'>RSS Feed</font><br>
The feed that just keeps on giving...<br>
<p>Title:<br>
<input type='text' name='title' size='84' /><br></p>
<p>Article Body:<br>
<textarea rows='20' cols='100' wrap='physical' name='desc'></textarea><br></p>
<input type='submit' value='Post RSS' name='submit'> (Be sure to review the article before pressing this button -- <b>there's no going back</b>)</form><br>
</body>
</html>
和Write.php
<html><body>
<?php
$file_name = 'rss.xml';
if !(file_exists($file_name)) {
initialize_xml($file_name);
}
$rss = fopen($file_name, 'w+') or die('can\'t open file');
remove_tags($rss);
write_content($rss);
close_tags($rss);
finish();
function initialize_xml($name) {
$rss = fopen($name, 'w') or die('can\'t open file');
fwrite($rss, "<?xml version=\"1.0\" ?>\n");
fwrite($rss, "<rss version=\"2.0\">\n");
fwrite($rss, "<channel>\n");
fwrite($rss, "<title>---</title>\n");
fwrite($rss, "<description>This feed will keep users up to date on IT issues that may arise</description>\n");
fwrite($rss, "<link>---</link>\n");
fwrite($rss, "<managingEditor>---</managingEditor>\n");
fwrite($rss, "<webMaster>---</webMaster>\n\n");
close_tags($rss);
fclose($rss);
}
function write_content($rss) {
fwrite($rss, '<item>\n');
fwrite($rss, '<title>');
fwrite($rss, $_POST['title']);
fwrite($rss, '</title>\n');
fwrite($rss, '<description>');
fwrite($rss, $_POST['desc']);
fwrite($rss, '</description>\n');
fwrite($rss, '<date>');
$today = getdate();
$timestamp_format = $today[weekday] + ' ' + $today[month] + ' ' + $today[mday] + ' ' + $today[hours] + ' ' + $today[minutes] + ' ' + $today[seconds];
fwrite($rss, $timestamp_format);
fwrite($rss, '</date>');
}
function close_tags($rss) {
fwrite($rss, '</channel>\n');
fwrite($rss, '</rss>\n');
fwrite($rss, '</xml>\n');
}
function remove_tags($rss) {
// go to end of file
// remove last 3 lines
}
function finish() {
echo 'The article ';
echo $_POST['title'];
echo ' has been added to the feed.\n';
echo '<a href="index.html">Go Back</a>';
}
?>
</body></html>
這是我與PHP的第一次接觸,所以我很困惑。 當我去到HTML頁面和「提交」我的形式,我重定向到:
HTTP錯誤500(內部服務器 錯誤):是 遇到意外情況,而服務器是 試圖履行請求。
感謝您的幫助
write.php和Write.php是不一樣的文件 – 2011-05-12 20:28:00
你用'在它\ N'所有的代碼,使用單引號(' '')榮獲'工作。它必須在雙引號內(''') – stealthyninja 2011-05-12 20:28:40
'$ today [weekday]','$ today [month]'等應該是'$ today ['weekday']','$ today [' ']'等' – stealthyninja 2011-05-12 20:30:03