完整的错误代码是"致命错误:未捕获错误:数组回调必须在C:\ xampp \ htdocs \ CSgroupproject \ profile.php中包含索引0和1:9堆栈跟踪:#0 {main}在第9行和第34行的C:\ xampp \ htdocs \ CSgroupproject \ profile.php中抛出;
我遇到问题的第一行是第9行。
$username = $_GET['username'];
这个问题的其他答案说括号应该是括号(我改变了)。还有问题。
这里是完整的代码:
指数:
<?php
//check if the form has been submitted
?>
<html>
<head>
<title>Search for a user:</title>
</head>
<body>
<h2>Search for a user below:</h2><br /><br />
<form action="profile.php" method="GET">
<table>
<tr><td>Username:</td><td><input type="test" id="username" name="username"></td></tr>
<tr><td><input type="submit" id="submit" name="submit" value="View Profile!"></td></tr>
</table>
</form>
</body>
</html>
资料:
<html>
<head>
<title><?php echo $username; ?></title>
</head>
<body>
<?php
//check for a form submission
if(isset($_GET['username'])){
$username = $_GET['username'];
$link = mysql_connect("mscs-mysql.uwstout.edu", "bandUser", "EricClapton84!") or die ("Could not connect to server"); //connect to server
mysql_select_db("users") or die ("That database could not be found");
$userquery = mysql_query("SELECT * FROM users WHERE username='$username'") or die("The query could not be completed. Please try again later.");
if (mysql_num_rows($userquery) != 1){
die ("That username could not be found");
}
//pull user info from database
while(mysql_fetch_array($userquery, MYSQL_ASSOC)){
$username = $column['user'];
/*$bio = $column['bio'];
$activated = $column['access'];*/
}
/*if($username != $user)
{
die ("Fatal error. Please try again later.");
}
if($activated == 0){
$active = "The account is not activated.";
} else {
$active = "The account has been activated.";
}
//see what level of access the user has
if($access == 0){
$admin = "This user is not an admin";
} else {
$admin = "This user is an admin";
}*/
?>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">WebSite</a>
</div>
<ul class="nav navbar-nav">
<li><a href="#">Home</a></li>
<li><a href="#">Concert Search</a></li>
<li class= "active">
<a href="fanProfile.html">Profile Page</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li id="profileLogin"><a href="fanProfile.html"> <span class="glyphicon glyphicon-user"></span>Profile</a></li>
<li><a href="Replace with logout stuff"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
</ul>
</div>
</nav>
<h2><?php echo $username; ?> <br /> <?php echo $bio; ?> </h2>
<table>
<tr><td><?php echo $username; ?></td></tr>
<tr><td><?php echo $bio; ?></td></tr>
<?php
mysql_close($link);
} else die ("Please specify username");
?>
</body>
</html>
答案 0 :(得分:0)
我明白了。我访问的文件是旧版本。我正在进行的更新不会转到xampp文件夹中的文件。