有人说是重定义了,可我看不出来,代码不长,大家帮我看看吧,代码如下:
<?phpinclude("class.fasttemplate.php3");
include_once("DB.php");$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;
$tpl = new FastTemplate("./templates");
$tpl->difine(array(main =>"index.tpl"));
$tpl->define_dynamic("row","main");$myOBJ = $myDB->connect($DSN);if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}$resultOBJ = $myOBJ->query("SELECT * FROM nervebook2");if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
return;
}
while ($row = $resultOBJ->fetchRow())
{
$tmpDate = array(substr($row[2],0,4),substr($row[2],4,2),substr($row[2],6,2));
$tmpDate = array(substr($row[2],8,2),substr($row[2],10,2),substr($row[2],12,2));
$date = implode("-",$tmpDate)." ". implode(":",$tmpDate);
$tpl->assign(NAME,$row[1]);
$tpl->assign(DATE,$date);
$tpl->assign(EMAIL,$row[3]);
$tpl->assign(HOMEPAGE,$row[4]);
$tpl->assign(MESSAGE,nl2br($row[5]));
$tpl->parse(ROWS,".row");
}$tpl->parse(BODY,"main");
$tpl->FastPrint("BODY");?>
<?phpinclude("class.fasttemplate.php3");
include_once("DB.php");$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;
$tpl = new FastTemplate("./templates");
$tpl->difine(array(main =>"index.tpl"));
$tpl->define_dynamic("row","main");$myOBJ = $myDB->connect($DSN);if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}$resultOBJ = $myOBJ->query("SELECT * FROM nervebook2");if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
return;
}
while ($row = $resultOBJ->fetchRow())
{
$tmpDate = array(substr($row[2],0,4),substr($row[2],4,2),substr($row[2],6,2));
$tmpDate = array(substr($row[2],8,2),substr($row[2],10,2),substr($row[2],12,2));
$date = implode("-",$tmpDate)." ". implode(":",$tmpDate);
$tpl->assign(NAME,$row[1]);
$tpl->assign(DATE,$date);
$tpl->assign(EMAIL,$row[3]);
$tpl->assign(HOMEPAGE,$row[4]);
$tpl->assign(MESSAGE,nl2br($row[5]));
$tpl->parse(ROWS,".row");
}$tpl->parse(BODY,"main");
$tpl->FastPrint("BODY");?>
这个FastTemplate是在php4.0.6及以前版本中使用的,不过他至今也没有再更新过搜索该文件,找到没有参数的clear_parse定义,并删除他
clear_parse()
在class.fasttemplate.php3 这个文件里
fasttemplate刚用时是会报这个错的,我以前用也是的
有两个clear_parse()
注释掉一个就行了
怎么用阿?
我找不到php5的教材,用的是php4的教材,而我机子上装的是php5的环境,所以总是有各种各样的错误,一个小小的留言本折腾我好几天了,我把文件发上,大家帮我看看吧。templates/index.tpl
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>nervebook2</title>
<style type="text/css">
<!--
.STYLE1 { font-family: "宋体";
font-size: 36px;
color: #0000FF;
}
.STYLE4 {
font-size: 18px;
color: #0066FF;
}
-->
</style>
</head><body>
<div align="center">
<p class="STYLE1">访客留言本</p>
<!BEGIN DYNAMIC BLOCK : row -->
<table width="80%" border="1">
<tr>
<td width="50%">访客:NAME</td>
<td width="50%">E-Mail:EMAIL</td>
</tr>
<tr>
<td>日期:DATE</td>
<td>HomePage:HOMEPAGE</td>
</tr>
<tr>
<td colspan="2">MESSAGE</td>
</tr>
</table>
<!END DYNAMIC BLOCK : row -->
<p> </p>
<form id="form1" name="form1" method="post" action="post.php">
<table width="80%" border="1">
<tr>
<td colspan="2"><div align="center"><span class="STYLE4">*我要留言*</span></div></td>
</tr>
<tr>
<td width="50%">访客</td>
<td width="50%"><label>
<input type="text" name="name" />
</label></td>
</tr>
<tr>
<td>E-Mail</td>
<td><label>
<input type="text" name="email" />
</label></td>
</tr>
<tr>
<td>HomePage</td>
<td><label>
<input type="text" name="homepage" />
</label></td>
</tr>
<tr>
<td>留言</td>
<td><label>
<textarea rows="5" name="message"></textarea>
<br />
<input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="重置" />
<br />
</label></td>
</tr>
</table>
</form>
<p class="STYLE1"> </p>
</div>
</body>
</html>index.php
<?phpinclude("class.fasttemplate.php3");
include_once("DB.php");$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;
$tpl = new FastTemplate("templates/");
$tpl->define(array(main => "index.tpl"));
$tpl->define_dynamic("row","main");$myOBJ = $myDB->connect($DSN);if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}$resultOBJ = $myOBJ->query("SELECT * FROM nervebook2");if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
return;
}
while ($row = $resultOBJ->fetchRow())
{
$tmpDate = array(substr($row[2],0,4),substr($row[2],4,2),substr($row[2],6,2));
$tmpDate = array(substr($row[2],8,2),substr($row[2],10,2),substr($row[2],12,2));
$date = implode("-",$tmpDate)." ". implode(":",$tmpDate);
$tpl->assign(NAME, $row[1]);
$tpl->assign(DATE, $date);
$tpl->assign(EMAIL, $row[3]);
$tpl->assign(HOMEPAGE, $row[4]);
$tpl->assign(MESSAGE, nl2br($row[5]));
$tpl->parse(ROWS,".row");
}$tpl->parse(BODY, "main");
$tpl->FastPrint("BODY");?>post.php
<?phpinclude_once("DB.php");$date = date("Y-m-d H:i:s");
$DSN = "mysql://root:mysql520@localhost/guestbook";
$myDB = new DB;$myOBJ = $myDB->connect($DSN);if ($myDB->isError($myOBJ))
{
echo $myOBJ;
return;
}
$sql = "INSERT INTO nervebook2 (name, date, email, homepage, message) VALUES('$_POST[name]','$_POST[date]','$_POST[email]','$_POST[homepage]','$_POST[message]')";
$rusultOBJ = $myOBJ->query($sql);
if ($myDB->isError($resultOBJ))
{
echo $resultOBJ;
}else {
header("Location: index.php");
}?>还有class.FastTemplate.php3和post.php大家知道的,另外表就一张,大家看得出来的,
大家帮我看看到底还有哪里有错,小弟不胜感激!
大家也可以把文件下了去看,地址是
http://www.tiantiansoft.com/bbs/viewFile.asp?BoardID=128&ID=13987
谢谢大家了
是这个地址..