0

我正在尝试回显我的会话,但它没有显示。我认为会话正在运行,因为这是与其他所有页面相同的代码。唯一显示的部分是文本...“您的 id 是”和“League Home”。有人可以帮我弄清楚我的代码有什么问题吗?

<?php
 // this starts the session 
 session_start();
 $id = $_SESSION['userid'];
 echo "Your id is " . $id;

//this connects to the database
$con = mysql_connect("localhost","yourfan3_jeengle","armyjoe30");
mysql_select_db("yourfan3_demo", $con);

 //gets info for user
 $result = mysql_query("SELECT * FROM League_Info WHERE User_ID = '$id'");  
 $result2 = mysql_fetch_array($result);
 $leaguename = $result2['League'];
 echo $leaguename;
 //$result31 = $result2['Members'];
 //$result32 = $result2['League_Password'];

 //checks if league name exists
 $memberslist = mysql_query("SELECT User_ID FROM League_Info WHERE League = '$leaguename'"); 

?>
<html>
<head>
</head>

<body>
League Home
</body>
</html>
4

3 回答 3

1

session 是一个特殊的数组,可以用来存储数据。如果您没有在代码中的其他位置设置 $_SESSION['userid'],您将无法在此处调用它。

于 2012-08-05T01:44:29.360 回答
0

You don't seem to set $_SESSION['userid']; in the code at all. Are you sure that there is an ID set when this is being run?

run this echo $_SESSION['userid']; and see if it returns anything?

于 2012-08-05T01:45:00.030 回答
0

You did not define $_SESSION['userid'] as anything, therefore there is nothing for it to echo. Make sure you give it a value then proceed with the echo.

于 2012-08-05T01:45:35.757 回答