PHP help with SQL.

Hello there community.

I’ve currently got this code:

[php]<?php
$db_host = “localhost”;
$db_username = “myuser”;
$db_pass = “mypass”;
$db_name = “mydb”;

mysql_connect("$db_host","$db_username","$db_pass") or die (“could not connect to mysql”);
mysql_select_db("$db_name") or die (“no database”);
$sql = “SELECT Username FROM Accounts WHERE Banned = 1”;
$rows = “”;
mysql_query($sql);
?>[/php]

Now I don’t understand how to do the rest, to display the ban list on my webpage.

All help is greatly appreciated,

Thanks!

removed $rows = “”; and continue from your last line of code

[php]
while($row = mysql_fetch_assoc($sql))
{
echo $row[‘Username’]."
";
}

[/php]

that should print all banned users line by line

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in … on line 12

can you post the code you have so we are updated

Sponsor our Newsletter | Privacy Policy | Terms of Service