這應該不是外掛的功能(當然,我有可能猜錯了 :P)
由於我用的虛擬主機,偶爾會連不上 MySQL,我就自己寫了個簡單程式輸出靜態頁面 HTML 作為備份。
請問我應該從那裡下手去改錯誤處理呢?
從錯誤訊息來看,可能是連結 MySQL 太多 threads 或是 memory 不足的錯誤,這是 pLog 的處理範圍嗎?
環境:
-----------------------------------------
Linux(不知道是哪個版本)
Apache Release 10333100
Apache API Version 19990320
PHP Version 4.3.11
MySQL Client API version 4.0.24
-----------------------------------------
我的超簡單輸出程式如下,提供給需要的人。
(由於這支程式輸出全部文章到同一個檔案,文章很多的人可能要考慮清楚這樣做是否合適,或者依情況自行修改)
----------------
<?php
// 參數設定
// 資料庫所在
$strMySQL = "xxx";
// 資料庫名稱
$strDatabase = "xxx";
// 資料庫使用者名稱
$strUserName = "xxx";
// 資料庫密碼
$strPassword = "xxx";
// plog 的資料表字首
$strPlogPrefix = "xxx";
// 輸出路徑,最後面要加斜線(目錄要設定為可讀寫,例如777)
$strArticleIndexPath = "xxx";
// 輸出備份檔名
$strOutput = "xxx";
// 聯結資料庫
$link = mysql_connect($strMySQL, $strUserName, $strPassword) or
die("mysql_connect() failed.");
mysql_select_db($strDatabase, $link) or
die("mysql_select_db() failed.");
// 放文章的變數
$strFileContent = <<<EOT
<html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="zh_TW" lang="zh_TW" dir="ltr">
<head>
<title>White Cloud's Blog</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body><center>
<font size=6 color=green>White Cloud's Blog</font>
<br>目前暫時連結不上資料庫,這是備份頁面<br><br>
EOT;
$strTable = $strPlogPrefix."articles_text";
$sql = "select article_id,topic,text from $strTable order by article_id desc";
$r = mysql_query($sql);
while ($row = mysql_fetch_object($r)) {
$strArticleID = $row->article_id;
$strTopic = $row->topic;
$strText = $row->text;
$strFileContent = $strFileContent.'<table width="80%" border="1"><tr><td>';
// $strFileContent = $strFileContent.$strArticleID;
// $strFileContent = $strFileContent."<br>";
$strFileContent = $strFileContent.'<font size=5><b>';
$strFileContent = $strFileContent.$strTopic;
$strFileContent = $strFileContent.'</b></font>';
$strFileContent = $strFileContent."<br><br>";
$strFileContent = $strFileContent.$strText;
$strFileContent = $strFileContent."<br><br>";
$strFileContent = $strFileContent."<td><tr><table><br><br>";
}
$strFileContent = $strFileContent."All content copyright
2004 White Cloud's Blog";
$strFileContent = $strFileContent."</center></body></html>";
// 輸出成為 HTML
//echo $strFileContent;
$fp = fopen($strArticleIndexPath.$strOutput, "w");
fputs($fp, $strFileContent);
fclose($fp);
echo "OK";
?>