将PHP注释框添加到我的网站
嗨,我已经设法制作了一个评论框,它依赖于mysql数据库和php编码的使用。我可以通过在服务器上打开index.php文件来运行注释框,但是当我尝试使用简单的include\u once php代码将其添加到html页面时 它似乎不起作用 请原谅,如果我听起来很愚蠢,但这是我第一次使用php 这是我一直试图使用的代码将PHP注释框添加到我的网站,php,Php,嗨,我已经设法制作了一个评论框,它依赖于mysql数据库和php编码的使用。我可以通过在服务器上打开index.php文件来运行注释框,但是当我尝试使用简单的include\u once php代码将其添加到html页面时 它似乎不起作用 请原谅,如果我听起来很愚蠢,但这是我第一次使用php 这是我一直试图使用的代码 <?php include_once("../connect.php"); $commenting_form = '<form action="add
<?php
include_once("../connect.php");
$commenting_form = '<form action="addcomment.php" method="post">
<table width="310" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><strong>Add Comment:</strong></td>
</tr>
<tr>
<td width="105">Title</td>
<td width="205"><input type="text" name="msg_title" id="msg_title" style="width:200px;" /></td>
</tr>
<tr>
<td colspan="2"><textarea name="msg_message" id="msg_message" style="width:100%;height:200px;font-family:Courier New">Message</textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Add Comment" name="msg_submit" id="msg_submit" /></td>
</tr>
</table>
</form>';
$get_comments = mysql_query("SELECT * FROM comments");
$comments_count = mysql_num_rows($get_comments);
if ($comments_count>0)
{
while ($com = mysql_fetch_array($get_comments))
{
$id = $com['id'];
$title = $com['text'];
$message = $com['message'];
$comment .= '<strong>'.$title.'</strong><br />'.$message.'<hr />';
}
$comment .= $commenting_form;
$page_title = $comments_count.' Comments';
}
else
{
$comment = 'There are no comments at the moment.<br />'.$commenting_form;
$page_title = 'No Comments';
}
?><!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=UTF-8" />
<title><?php echo $page_title; ?></title>
</head>
<body>
<?php
echo $comment;
?>
</body>
</html>
试试这个:
include "../connect.php";
注意:请确保将connect.php的路径设置为正确的路径
无法在HTML页面上执行php,您需要使用.php
扩展名。是否收到错误?出现了什么错误?您只需要保存page.php扩展名。当用户第一次使用php时,为什么人们会放弃投票呢。