Getting [] not supported for string but its an array
Posted: Tue Jul 29, 2003 4:14 pm
I have code that gets users from a mysql database table 'chat_users' and puts them into an array. I then have it display the users in a foreach() command. It gives me an error saying the [] operator not supported for strings, but the query gives an array. Whats wrong? Heres the code:
Code: Select all
<?
$name = $_GETїusername];
$server = "not shown for security reasons";
$database = "not shown for security reasons";
$user = "not shown for security reasons";
$password = "not shown for security reasons";
$link = mysql_connect($server, $user, $password)
or die("Could not connect");
mysql_select_db($database, $link) or die("Could not select database");
$userquery = "SELECT * FROM chat_users"
$userresult = mysql_query($userquery, $link) or die("Query failed Number 1");
while ($row2 = mysql_fetch_row($userresult))
{
$userї]=$row2;
}
mysql_free_result($userresult);
echo "<b/>Users Online:</b><br/>";
foreach ($user as $poster)
{
$username = $posterї"user"];
echo "- $username<br/>";
}
?>