我想做一个从主页引导的个人资料页面,当我登录并点击个人资料页面时,我有这个 2 错误。我想显示名字和姓氏。
Notice: Undefined variable: first_name in C:\xampp\htdocs\FontLibrary\Profile.php on line 181
和
Notice: Undefined variable: last_name in C:\xampp\htdocs\FontLibrary\Profile.php on line 183
但是我已经在 if 语句中定义了它?
相关代码是
<?php
session_start();
include 'dbfunctions.php';
$msg = "";
$id = $_SESSION['id'];
if (!isset($id)) {
$id = $_SESSION['id'];
}
// Build the SELECT statement
$select_query = "SELECT * FROM users WHERE id = ".$id;
//Run the Query
$result = mysql_query($select_query);
if ($result) {
$row = mysql_fetch_array($result);
$first_name = $row['first_name'];
$last_name = $row['last_name'];
}
?>
和
First Name:<?php echo $first_name ?> <br />
Last Name:<?php echo $last_name ?> <br />