I have a MySQL Database setup like so:
id | username
-------------
1 | name1
2 | name2
3 | name3
But when I use this code in PHP, it only reads the first name. NOTE: I need it to read just the names. The id is there for something else.
$sql = mysql_query("SELECT `username` FROM `black_list`");
$blacklist = array();
while($row = mysql_fetch_array($sql))
{
$blacklist[] = $row;
if(!in_array($name,$blacklist))
{
//User not protected
} else {
echo "User Protected";
}
}
If anyone could help me, that would be great. Thanks :)
mysql_*functions in new code. They were removed from PHP 7.0.0 in 2015. Instead, use prepared statements via PDO or MySQLi. See Why shouldn't I use mysql_* functions in PHP? for more information.