PHP Chat Problems
Posted: Tue Jul 29, 2003 10:21 am
Hello, I am making a web chat for my website and have the following script to get info from the mysql database. For Some reason, it says
but it isnt a string, its an array, as you can see in the second part, they're exactly the same, even the tables in the database are the same, but for some reason, its not letting me get the info. Please help. Thanks[] operator not supported for strings
Code: Select all
<?php
echo "<meta http-equiv="Refresh" content="5">";
$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";
$def = "1";
$link = mysql_connect($server, $user, $password)
or die("Could not connect");
mysql_select_db($database, $link) or die("Could not select database");
$query = "SELECT * FROM chat_users WHERE def=$def";
$result = mysql_query($query, $link) or die("Query failed Number 1");
while ($row2 = mysql_fetch_row($result))
{
$userї]=$row2;
}
mysql_free_result($result);
echo "<table border="1"><tr>Welcome to the =AATA= Web Chat $name!<tr><td width="100"><b>Users Online:</b><br/>";
foreach ($user as $poster)
{
$username = $posterї0];
echo "- $username<br/>";
}
echo "</td><td width="500">";
$query = "SELECT * FROM chat_posts WHERE def=$def";
$result = mysql_query($query, $link) or die("Query failed Number 2");
while ($row3 = mysql_fetch_row($result))
{
$postsї]=$row3;
}
mysql_free_result($result);
$posts = array_reverse($posts);
foreach ($posts as $post)
{
$postername = $postї0];
$postertext = $postї1];
$posternum = $postї3];
echo "<b/>$postername Says:</b> $postertext";
echo "<br/>";
}
?>