在我的代码中,我有两个文件; connection.php和test.php
这是我的connection.php;
的代码<?php
session_id();
session_start();
ob_start();
date_default_timezone_set('America/Chicago');
$link = mysql_connect('localhost', 'induadmi_main', '$admiNiNd/U');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$User = $_SESSION['Username'];
$Admin = $_SESSION['Admin'];
if ($User) {
$MyUser = mysql_query("SELECT * FROM Users WHERE Username='SamDreadrage'");
$myU = mysql_fetch_object($MyUser);
var_dump($myU);
$UserExist = mysql_num_rows($MyUser);
if ($UserExist == "0") {
session_destroy();
header("Location: /index.php");
}
}
这是针对test.php;
<?php
include "connection.php";
echo 'password', $myU->Password;
?>
test.php只回显&#34;密码&#34;,而不是回复&#34;密码TestPassword&#34;喜欢它。 connection.php还包括我测试过的工作连接,并确保所有表SELECT * FROM Users WHERE Username =&#39; SamDreadrage&#39;在phpMyAdmin中工作,所以我没有看到问题。