PHP会话未在特定脚本上被识别

时间:2011-10-21 15:36:27

标签: php

创建了userid SESSION,但是在这个特定的脚本上,我得到了“注意:未定义的变量:C:\ Workspace中的_SESSION ......第6行的process-request.php”错误。有什么想法吗?

<?php
if(isset($_GET['id'])) {
    echo $_GET['id'] . ": ";
}
if(isset($_GET['accepted'])) {
    $id = $_SESSION['userid'];
        mysql_connect("localhost", "root", "")or die("Could not connect: " . mysql_error());
        mysql_select_db("druvla_public") or die(mysql_error());
        mysql_query("INSERT IGNORE INTO requests (RequestSentByID, RequestRecipientID, StatusType, AddedMessage, FriendType)
            VALUES(1, '$id', 'Accepted', 'Welcome to Druvla', 'full')")or die(mysql_error());
    }
if(isset($_GET['denied'])) {
    echo "success";
}
?>

1 个答案:

答案 0 :(得分:3)

您忘了拨打session_start()