这是我的代码:
<?php
include("inc/incfiles/header.inc.php");
session_start();
$user_id = $_SESSION["id"];
if (!isset($_SESSION["id"])) {
header("location: index.php");
}
else {
echo "Welcome, user number " . $user_id . ". This is you're newsfeed!";
echo "<br><a href=\"logout.php\">Log Off?</a>";
}
echo "<br><br>";
$userFname = mysql_query("SELECT first_name FROM users WHERE id=$user_id");
$userLname = mysql_query("SELECT last_name FROM users WHERE id=$user_id");
echo "First Name: " . $userFname . "<br>";
echo "Last Name: " . $userLname . "<br>"; ?>
header.inc.php 文件仅用于 sql 连接和 html 标头。
我现在的问题是,当我调用名字和姓氏时,它只会给出输出“资源 ID #6”和“资源 ID #7”。我不明白为什么它不显示实际的名字和姓氏?