-1

存在错误消息:

致命错误:在第 22 行的 /var/www/New/API/Constants.php 中的非对象上调用成员函数 bind_param()

更新了整个 constants.php 这是我在 constants.php 上的代码:

session_start();
if (isset($_SESSION['real_name']))
{
    $username = $_SESSION['real_name'];

    $InnerJoinQuery = $STD->prepare("
    SELECT Users.ID, Users.Password, UserInformation.LastName, UserInformation.Firstname, UserInformation.DOB
    FROM Users
    INNER JOIN UserInformation
    ON Users.ID = UserInformation.UserID WHERE Users.Username = ?");
    $InnerJoinQuery->bind_param("s", $username);
    $InnerJoinQuery->execute();
    $InnerJoinQuery->bind_result($UID, $Password, $LastName, $Firstname, $DOB);
    $InnerJoinQuery->fetch();

    $_SESSION['UID'] = $UID;
    $_SESSION['Password'] = $Password;
    $_SESSION['Firstname'] = $LastName;
    $_SESSION['LastName'] = $Firstname;
    $_SESSION['DOB'] = $DOB;
}

    echo $UID."<br>".$Password."<br>".$LastName."<br>".$Firstname."<br>".$DOB;

但:

echo $UID."<br>".$Password."<br>".$LastName."<br>".$Firstname."<br>".$DOB;

退货;

5 xxx 吉尔达里尔 211094

还:

print_r($_SESSION);

数组([real_name] => InhumaneSlayer [Password] => xxx [UID] => 5 [Firstname] => Gill [LastName] => Daryl [DOB] => 211094)

以上是预期输出

哪个是预期的?所以 bind_param 失败但 bind_results 正在收集正确的信息?

4

2 回答 2

0

做这个:

    @session_start();
$username = $_SESSION['real_name'];

if (isset($username))
{

对此:

session_start();
if (isset($_SESSION['real_name']))
{
    $username = $_SESSION['real_name'];

…………

$InnerJoinQuery->bind_param("s", $username);

您是否检查过会话以确保已设置。我认为你的名字和姓氏是倒着的:

$_SESSION['UID'] = $UID;
$_SESSION['Password'] = $Password;
$_SESSION['Firstname'] = $LastName;
$_SESSION['LastName'] = $Firstname;
$_SESSION['DOB'] = $DOB;

尝试回应:

echo $_SESSION['UID']."<br/>" ;
echo $_SESSION['Password']."<br/>" ;
echo $_SESSION['Firstname']."<br/>" ;
echo $_SESSION['LastName'] ."<br/>" ;
echo $_SESSION['DOB'] ."<br/>" ;
echo $_SESSION['real_name']."<br/>" ;
于 2013-01-15T21:42:15.690 回答
0

如果这是您的完整页面,您将如何获得$STD我认为是您的连接变量的信息。

如果您要包括数据库和来自不同页面的此页面....包括您的数据库文件。

改变:

session_start();
if (isset($_SESSION['real_name']))
{

到:

include "YourFile";
session_start();
if (isset($_SESSION['real_name']))
{
于 2013-01-15T22:53:36.710 回答