我正在关注一个视频系列,并且由于某种原因,与我使用的代码相同的代码不起作用。我收到此错误:
警告:第 8 行 /Applications/XAMPP/xamppfiles/htdocs/projects/lr/core/functions/general.php 中为 foreach() 提供的参数无效
我的 general.php 页面是:
<?php
function sanitize($data) {
return mysql_real_escape_string($data);
}
function output_errors($errors) {
$output = array();
foreach($errors as $error) {
echo $error, ', ';
}
}
我的 login.php 页面是:
<?php
include 'core/init.php';
if (empty($_POST) === false) {
$username = $_POST['username'];
$password = $_POST['password'];
if (empty($username) === true|| empty($password) === true) {
$errors[] = 'You need to enter a username and/or password.';
} else if (user_exists($username) === false) {
$errors[] = 'We can\'t find that username. Have you registered?';
} else if (user_active($username) === false) {
$errors[] = 'You haven\'t activated your account! Check your email.';
} else {
$login = login($username, $password);
if ($login === false) {
$errors = 'That username/password combination is incorrect.';
} else{
$_SESSION['user_id'] = $login;
?>
<meta http-equiv="refresh" content="0;url=index.php">
<?php
exit();
}
}
}else {
$errors[] = 'No data received';
}
include 'includes/overall/overall_header.php';
output_errors($errors);
include 'includes/overall/overall_footer.php';
?>
视频集在这里:http ://www.youtube.com/watch?v=-XvbXxqJ4xQ&list=ECE134D877783367C7但我没有得到相同的结果。谢谢你。