Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有评论类型注释的问题_Php_Phpmyadmin - Fatal编程技术网

Php 带有评论类型注释的问题

Php 带有评论类型注释的问题,php,phpmyadmin,Php,Phpmyadmin,嘿,伙计们,我想知道我是否可以得到一些帮助,我正在为一个项目建立一个网站。它几乎完成了,但我正在努力完成其中的一部分,这基本上就是评论 我正在创建一个电影评论网站,有点像IMDB.com,但我的网站只是为了上课,但我真的在为我真正想工作的部分而挣扎 对我来说,理想的情况是,有人能够键入他们想要搜索的电影,然后在他们推送提交后,他们被带到另一个页面。在该页面上,电影信息,如电影名称、描述、类型、分级等。。。在这下面,是人们对这部电影的看法。但是,有一件事我不能理解,当有人在《阿凡达》中输入时,电影

嘿,伙计们,我想知道我是否可以得到一些帮助,我正在为一个项目建立一个网站。它几乎完成了,但我正在努力完成其中的一部分,这基本上就是评论

我正在创建一个电影评论网站,有点像IMDB.com,但我的网站只是为了上课,但我真的在为我真正想工作的部分而挣扎

对我来说,理想的情况是,有人能够键入他们想要搜索的电影,然后在他们推送提交后,他们被带到另一个页面。在该页面上,电影信息,如电影名称、描述、类型、分级等。。。在这下面,是人们对这部电影的看法。但是,有一件事我不能理解,当有人在《阿凡达》中输入时,电影评论就会出现,但当他们在《幽灵骑士》中输入时,会出现完全相同的评论,如果这有意义的话,我希望他们分开

对于我的桌子,我有

电影

评论

我只是在一个停顿的这一部分,这是一种困扰我,我已经找了不少地方,仍然未能找到我要寻找的。 这是我的代码,我很遗憾地告诉大家,我不太擅长PHP或编程。所有这些都是在dreamweaver中完成的,所以如果它看起来很凌乱,那就是原因

<?php require_once('../Connections/lesson6.php'); ?>

<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php require_once('../Connections/lesson6.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
// For security, start by assuming the visitor is NOT authorized. 
$isValid = False; 

// When a visitor has logged into this site, the Session variable MM_Username set equal      to their username. 
// Therefore, we know that a user is NOT logged in if that Session variable is blank. 
if (!empty($UserName)) { 
// Besides being logged in, you may restrict access to only certain users based on an    ID established when they login. 
// Parse the strings into arrays. 
$arrUsers = Explode(",", $strUsers); 
$arrGroups = Explode(",", $strGroups); 
if (in_array($UserName, $arrUsers)) { 
  $isValid = true; 
} 
// Or, you may restrict access to only certain users based on their username. 
if (in_array($UserGroup, $arrGroups)) { 
  $isValid = true; 
} 
if (($strUsers == "") && true) { 
  $isValid = true; 
} 
} 
return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers,      $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" .   urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo); 
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",   $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",   $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

$colname_GetMovie = "-1";
if (isset($_GET['Search'])) {
$colname_GetMovie = $_GET['Search'];
}
mysql_select_db($database_lesson6, $lesson6);
$query_GetMovie = sprintf("SELECT * FROM movie WHERE MovieName = %s",      GetSQLValueString($colname_GetMovie, "text"));
$GetMovie = mysql_query($query_GetMovie, $lesson6) or die(mysql_error());
$row_GetMovie = mysql_fetch_assoc($GetMovie);
$totalRows_GetMovie = mysql_num_rows($GetMovie);

mysql_select_db($database_lesson6, $lesson6);
$current_MovieID=MovieID;
$query_Recordset1 = "SELECT * FROM reviews WHERE MovieID=$current_MovieID";
$Recordset1 = mysql_query($query_Recordset1, $lesson6) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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>Results</title>
<link href="styles/style_sheet.css" rel="stylesheet" type="text/css" />



<style type="text/css">
a:link {
color: #0F0;
}
a:visited {
color: #0F0;
}
</style>
</head>
<body>

<div id="main_container">
<div id="header">

</div><!--End of header-->
<div class="shadow">
<div id="navbar"><a href="index.php">Home</a> &nbsp;&nbsp;&nbsp; <a     href="register.php">Register</a> &nbsp;&nbsp;&nbsp; <a href="login.php">Login</a> / <a href="<?php echo $logoutAction ?>">Logout</a> &nbsp;&nbsp;&nbsp; <a   href="Search.php">Search</a></div><!--End of NavBar-->
</div><!--End of navbar shadow-->
<br />
<div class="shadow">
<div id="Content">
<h2> Results:</h2>
<?php if ($totalRows_GetMovie == 0) { // Show if recordset empty ?>
<form id="form1" name="form1" method="post" action="">
Sorry, there was no movie with that name in the database. Click <a   href="Search.php">here</a> to search again.
</form>
<?php } // Show if recordset empty ?>
<p>&nbsp;</p>
<?php if ($totalRows_GetMovie > 0) { // Show if recordset not empty ?>
<form action="" name="Movie_Search"method="get">
<p>Movie Name: <?php echo $row_GetMovie['MovieName']; ?></p>
<p> Movie Description: <?php echo $row_GetMovie['Description']; ?></p>
<p>Genre: <?php echo $row_GetMovie['Genre']; ?></p>
<p>Rating: <?php echo $row_GetMovie['Rating']; ?></p>
<p>&nbsp;</p>
</form>
<?php } // Show if recordset not empty ?>
<label for="movie_search"></label>
<form action="" method="get">
<center><h2>Reviews</h2></center>
<?php do { ?>
<table width="566">
  <tr>
    <td width="20" height="97"><p><img src="Pictures/Male-User-icon.png" width="67"  height="67" /></p></td>
    <td width="534"><p> <?php echo $row_Recordset1['Name']; ?> says:</p>
      <p><?php echo $row_Recordset1['Review']; ?></p>
      <p>-------------------------------------------------------------------------------------------------</p></td>
  </tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form id="insert_comments" s style="border:thin" name="insert_comments"   method="POST"first_name">
First Name:</label>
<br />
  <input type="text" name="first_name" id="first_name" />
<br>
  <label for="desc">Comments:<br /></label>
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>

<p>&nbsp;</p>
</div>
<!--End of Contentr-->
</div><!--End of content shadow-->

<div class="footer">

<hr />© Nate Christensen<hr />
</div><!--End of footer-->
</div><!--End of Main Container-->


</body>
</html>
<?php
mysql_free_result($GetMovie);

mysql_free_result($Recordset1);

?>

评论表包含评论,对吗?我可以看到您在那里有一个MovieID列,因此您应该能够在MovieID=“$current\u movie\u id”的条件下查询数据库,以便仅获取特定电影的评论。

抱歉,我不理解您的问题。选择*FROM Reviews,其中MovieID=$MovieID ORDER BY ReviewID DESC?是的,您是对的,review表包含注释。这是有道理的,虽然我的课程使用dreamweaver,基本上一直都是你,所以我试着用所有这些服务器行为来做,但现在这就像是在我的头上,如果我能以某种方式发布我的代码,那将是一团混乱。但是古斯塔夫,这对于Where条款来说确实有意义。但还有一个快速问题,我如何声明$current\u movie\u id?
ReviewID, Name, Review, MovieID
<?php require_once('../Connections/lesson6.php'); ?>

<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "index.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php require_once('../Connections/lesson6.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
// For security, start by assuming the visitor is NOT authorized. 
$isValid = False; 

// When a visitor has logged into this site, the Session variable MM_Username set equal      to their username. 
// Therefore, we know that a user is NOT logged in if that Session variable is blank. 
if (!empty($UserName)) { 
// Besides being logged in, you may restrict access to only certain users based on an    ID established when they login. 
// Parse the strings into arrays. 
$arrUsers = Explode(",", $strUsers); 
$arrGroups = Explode(",", $strGroups); 
if (in_array($UserName, $arrUsers)) { 
  $isValid = true; 
} 
// Or, you may restrict access to only certain users based on their username. 
if (in_array($UserGroup, $arrGroups)) { 
  $isValid = true; 
} 
if (($strUsers == "") && true) { 
  $isValid = true; 
} 
} 
return $isValid; 
}

$MM_restrictGoTo = "login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers,      $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" .   urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo); 
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",   $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",   $theNotDefinedValue = "") 
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ?   mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;    
case "long":
case "int":
  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  break;
case "double":
  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  break;
case "date":
  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  break;
case "defined":
  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  break;
}
return $theValue;
}
}

$colname_GetMovie = "-1";
if (isset($_GET['Search'])) {
$colname_GetMovie = $_GET['Search'];
}
mysql_select_db($database_lesson6, $lesson6);
$query_GetMovie = sprintf("SELECT * FROM movie WHERE MovieName = %s",      GetSQLValueString($colname_GetMovie, "text"));
$GetMovie = mysql_query($query_GetMovie, $lesson6) or die(mysql_error());
$row_GetMovie = mysql_fetch_assoc($GetMovie);
$totalRows_GetMovie = mysql_num_rows($GetMovie);

mysql_select_db($database_lesson6, $lesson6);
$current_MovieID=MovieID;
$query_Recordset1 = "SELECT * FROM reviews WHERE MovieID=$current_MovieID";
$Recordset1 = mysql_query($query_Recordset1, $lesson6) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!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>Results</title>
<link href="styles/style_sheet.css" rel="stylesheet" type="text/css" />



<style type="text/css">
a:link {
color: #0F0;
}
a:visited {
color: #0F0;
}
</style>
</head>
<body>

<div id="main_container">
<div id="header">

</div><!--End of header-->
<div class="shadow">
<div id="navbar"><a href="index.php">Home</a> &nbsp;&nbsp;&nbsp; <a     href="register.php">Register</a> &nbsp;&nbsp;&nbsp; <a href="login.php">Login</a> / <a href="<?php echo $logoutAction ?>">Logout</a> &nbsp;&nbsp;&nbsp; <a   href="Search.php">Search</a></div><!--End of NavBar-->
</div><!--End of navbar shadow-->
<br />
<div class="shadow">
<div id="Content">
<h2> Results:</h2>
<?php if ($totalRows_GetMovie == 0) { // Show if recordset empty ?>
<form id="form1" name="form1" method="post" action="">
Sorry, there was no movie with that name in the database. Click <a   href="Search.php">here</a> to search again.
</form>
<?php } // Show if recordset empty ?>
<p>&nbsp;</p>
<?php if ($totalRows_GetMovie > 0) { // Show if recordset not empty ?>
<form action="" name="Movie_Search"method="get">
<p>Movie Name: <?php echo $row_GetMovie['MovieName']; ?></p>
<p> Movie Description: <?php echo $row_GetMovie['Description']; ?></p>
<p>Genre: <?php echo $row_GetMovie['Genre']; ?></p>
<p>Rating: <?php echo $row_GetMovie['Rating']; ?></p>
<p>&nbsp;</p>
</form>
<?php } // Show if recordset not empty ?>
<label for="movie_search"></label>
<form action="" method="get">
<center><h2>Reviews</h2></center>
<?php do { ?>
<table width="566">
  <tr>
    <td width="20" height="97"><p><img src="Pictures/Male-User-icon.png" width="67"  height="67" /></p></td>
    <td width="534"><p> <?php echo $row_Recordset1['Name']; ?> says:</p>
      <p><?php echo $row_Recordset1['Review']; ?></p>
      <p>-------------------------------------------------------------------------------------------------</p></td>
  </tr>
</table>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form id="insert_comments" s style="border:thin" name="insert_comments"   method="POST"first_name">
First Name:</label>
<br />
  <input type="text" name="first_name" id="first_name" />
<br>
  <label for="desc">Comments:<br /></label>
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</p>
<p>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>

<p>&nbsp;</p>
</div>
<!--End of Contentr-->
</div><!--End of content shadow-->

<div class="footer">

<hr />© Nate Christensen<hr />
</div><!--End of footer-->
</div><!--End of Main Container-->


</body>
</html>
<?php
mysql_free_result($GetMovie);

mysql_free_result($Recordset1);

?>