这里的错误是代码:让我的foreach循环
<?php
//Starting session
session_start();
//Includes mass includes containing all the files needed to execute the full script
//Also shows homepage elements without customs
require_once ('includes/mass.php');
$username = $_SESSION['username'];
if (isset($username))
{
//Query database for the users networths
$sq_l = "SELECT * FROM user ORDER BY worth";
$sql_query_worth = mysql_query($sq_l);
while ($row = mysql_fetch_assoc($sql_query_worth))
{
$dbusername = $row['username'];
$dbworth = $row['worth'];
foreach ($dbusername as $dbuser)
{
echo ". USER: ".$dbuser." Has a networth of: ".$dbworth;
}
}
}
?>
有三种结果。这里是错误。
以下是错误消息:
警告:(c)中提供的foreach参数无效:\ XAMPP \ htdocs中\ Mogul公司\上线richlist.php 32
警告:无效参数提供为的foreach ()在C:\ XAMPP \ htdocs中\ Mogul公司\上线richlist.php 32
警告:在C的foreach()提供参数无效:\ XAMPP \ htdocs中\ Mogul公司\ richlist.php在线路32
看来'$ dbusername'不是一个数组。 – Gumbo 2010-03-12 16:51:08
那是什么“foreach”?是不是'$ dbusername''一个字符串? – kennytm 2010-03-12 16:51:57
你想完成什么?错误信息很清楚,循环没有任何意义。 – 2010-03-12 16:52:15