我正在尝试将会话变量从一个页面传递到另一个页面,但看起来会话变量在下一页上是空的。谢谢您的帮助!
这是两页上的全部代码。
mysql_connect($db_hostname, $db_username, $db_password);
mysql_select_db($db_sitename);
$pagename= $row_getDisplay['USER_NAME'];
$query=mysql_query("SELECT * FROM COMMENTS WHERE COMMENT_ON='$pagename' LIMIT 0, $no_of_comments");
echo "<hr />";
echo "<h3>Latest Comments</h3>";
session_start();
$count = 0;
while($fetch=mysql_fetch_array($query))
{
echo "<p>".$fetch['COMMENT']."<a href=delete_comment.php?count=".$count.">X</a><br/><sub><b>Comment by: </b>".$fetch['COMMENT_BY']."</sub><hr /><p>";
$_SESSION[strval($count)]=$fetch['COMMENT'];
//echo $_SESSION[strval($count)];
$count = $count + 1;
print_r($_SESSION);
}
mysql_close();
删除评论.php
<?php
session_start();
print_r($_SESSION);
error_reporting(E_ALL);
ini_set('display_errors', '1');
$count = $_GET['count'];
echo $count;
$comment = $_SESSION[strval($count)];
$db_sitename="genydb";
$db_hostname="localhost";
$db_username=
$db_password=
$con = mysqli_connect($db_hostname, $db_username, $db_password, $db_sitename);
echo $comment;
$myquery = sprintf("DELETE FROM COMMENTS WHERE COMMENT=%s", GetSQLValueString($_SESSION[$_GET['count']], 'text'));
$mysql=($myquery) or die(mysql_error());
mysqli_close($con);
?>
这是错误
Notice: Undefined offset: 0 in /var/www/geny/bootstrap/delete_comment.php on line 8
$comment = $_SESSION[strval($count)];