<?php/**
* @author chengang
* @copyright 2009
*/
/* connect to the database */
mysql_pconnect("$host","$user","$password") or die("Can’t connect to the SQL-server");
mysql_select_db("$database"); /* action=view : retrieve data from the database and show it to the user */
if($action == "view") { /* function for showing the data */
function search_it($name) { /* some vars */
global $offset,$total,$lpp,$dir;
global $table,$html_mail,$admin_name,$admin_mail; /* select the data to get out of the database */
$query = "SELECT name, email, job, comments FROM $table";
$result = mysql_query($query);
$total= mysql_numrows($result); print "<CENTER><FONT FACE="Verdana" SIZE="-2"><A HREF="guestbook.php3?action=add" onMouseOver="window.status=’Add your name’;return true" onMouseOut="window.status=’’;return true" TITLE="Add your name">加入留言</A></FONT></CENTER><br><br>"; if ($total== 0) {
print "<CENTER>此刻没人留言</CENTER><br><br>"; } elseif ($total> 0) { /* default */
$counter=0;
if ($dir=="") $dir="Next";
$lpp=5;
if ($offset==0) $offset=0; if ($dir=="Next") { if ($total > $lpp) { $counter=$offset;
$offset+=$lpp;
$num=$offset; if ($num > $total) {
$num=$total; } } else {
$num=$total; } } elseif ($dir=="Previous") { if ($total > $lpp) {
$offset-=$lpp; if ($offset < 0) {
$offset=0; } $counter=$offset-$lpp; if ($counter < 0)
$counter=0;
$num=$counter+$lpp; } else {
$num=$total; } } while ($counter < $num) {
$j=0;
$j=$counter + 1; /* now really grab the data */
$i1=mysql_result($result,$counter,"name");
$i2=mysql_result($result,$counter,"email");
$i3=mysql_result($result,$counter,"job");
$i4=mysql_result($result,$counter,"comments"); $i4 = stripslashes ("$i4"); /* print it in a nice layout */
print "<CENTER>n";
print "<TABLE WIDTH=400 BORDER=0 ALIGN=CENTER VALIGN=TOP><TR><TD><FONT FACE="Verdana" SIZE="-2">n";
print "<HR>n";
print "<BR><B>Name:</B> $i1n";
print "<BR><B>email:</B><A HREF="mailto:$i2" onMouseOver="window.status=’Email $i2’;return true" onMouseOut="window.status=’’;return true" TITLE="Email $i2">$i2</A>n";
print "<BR><B>Job:</B> $i3n";
print "<BR><B>Comment:</B>n";
print "<BR>$i4n";
print "</FONT></TD></TR></TABLE>n";
print "</CENTER>n";
$counter++;
}
}
mysql_close();
} /* execute the function */
search_it($name); /* See if we need to put on the NEXT or PREVIOUS buttons */
if ($total > $lpp) {
echo("<form action="$PHP_SCRIPT" method="POST">n"); /* See if we need a PREVIOUS button */
if ($offset > $lpp) {
echo("<input type="submit" value="Previous" name=dir>n"); } /* See if we need a NEXT button */
if ($offset < $total) {
echo("<input type="submit" value="Next" name=dir>n"); } echo("<input type=hidden name="offset" value="$offset">n");
echo("<input type=hidden name="name" value="$name">n");
echo("</form>");
}
} /* action=add : show a form where the user can enter data to add to the database */
elseif($action == "add") {
?>Parse error 28Line PHP Prase
请求高手帮助!!!
* @author chengang
* @copyright 2009
*/
/* connect to the database */
mysql_pconnect("$host","$user","$password") or die("Can’t connect to the SQL-server");
mysql_select_db("$database"); /* action=view : retrieve data from the database and show it to the user */
if($action == "view") { /* function for showing the data */
function search_it($name) { /* some vars */
global $offset,$total,$lpp,$dir;
global $table,$html_mail,$admin_name,$admin_mail; /* select the data to get out of the database */
$query = "SELECT name, email, job, comments FROM $table";
$result = mysql_query($query);
$total= mysql_numrows($result); print "<CENTER><FONT FACE="Verdana" SIZE="-2"><A HREF="guestbook.php3?action=add" onMouseOver="window.status=’Add your name’;return true" onMouseOut="window.status=’’;return true" TITLE="Add your name">加入留言</A></FONT></CENTER><br><br>"; if ($total== 0) {
print "<CENTER>此刻没人留言</CENTER><br><br>"; } elseif ($total> 0) { /* default */
$counter=0;
if ($dir=="") $dir="Next";
$lpp=5;
if ($offset==0) $offset=0; if ($dir=="Next") { if ($total > $lpp) { $counter=$offset;
$offset+=$lpp;
$num=$offset; if ($num > $total) {
$num=$total; } } else {
$num=$total; } } elseif ($dir=="Previous") { if ($total > $lpp) {
$offset-=$lpp; if ($offset < 0) {
$offset=0; } $counter=$offset-$lpp; if ($counter < 0)
$counter=0;
$num=$counter+$lpp; } else {
$num=$total; } } while ($counter < $num) {
$j=0;
$j=$counter + 1; /* now really grab the data */
$i1=mysql_result($result,$counter,"name");
$i2=mysql_result($result,$counter,"email");
$i3=mysql_result($result,$counter,"job");
$i4=mysql_result($result,$counter,"comments"); $i4 = stripslashes ("$i4"); /* print it in a nice layout */
print "<CENTER>n";
print "<TABLE WIDTH=400 BORDER=0 ALIGN=CENTER VALIGN=TOP><TR><TD><FONT FACE="Verdana" SIZE="-2">n";
print "<HR>n";
print "<BR><B>Name:</B> $i1n";
print "<BR><B>email:</B><A HREF="mailto:$i2" onMouseOver="window.status=’Email $i2’;return true" onMouseOut="window.status=’’;return true" TITLE="Email $i2">$i2</A>n";
print "<BR><B>Job:</B> $i3n";
print "<BR><B>Comment:</B>n";
print "<BR>$i4n";
print "</FONT></TD></TR></TABLE>n";
print "</CENTER>n";
$counter++;
}
}
mysql_close();
} /* execute the function */
search_it($name); /* See if we need to put on the NEXT or PREVIOUS buttons */
if ($total > $lpp) {
echo("<form action="$PHP_SCRIPT" method="POST">n"); /* See if we need a PREVIOUS button */
if ($offset > $lpp) {
echo("<input type="submit" value="Previous" name=dir>n"); } /* See if we need a NEXT button */
if ($offset < $total) {
echo("<input type="submit" value="Next" name=dir>n"); } echo("<input type=hidden name="offset" value="$offset">n");
echo("<input type=hidden name="name" value="$name">n");
echo("</form>");
}
} /* action=add : show a form where the user can enter data to add to the database */
elseif($action == "add") {
?>Parse error 28Line PHP Prase
请求高手帮助!!!
这句的字符串输出有问题,字符串之间的连接要用"."号,如果是引号中还有引用应该用'',例如:print "<CENTER> <FONT FACE='Verdana' SIZE='-2'>", 要不然会解析错误。
print " <CENTER> <FONT FACE=\"Verdana\" SIZE=\"-2\"> <A HREF=\"guestbook.php3?action=add\" onMouseOver=\"window.status=’Add your name’;return true\" onMouseOut=\"window.status=’’;return true\" TITLE=\"Add your name\">加入留言 </A> </FONT> </CENTER> <br> <br>";
你没加转义所以错了。或者你将引用的双引号改成单引号 '',就行了。130行也是类似错误。