Отображение MySQLi в коде PHP

0

Моя проблема заключается в том, что я не могу войти в систему с этим, потому что по какой-то причине он не позволяет мне, если у меня есть код, получающий данные из базы данных, он не работает (у меня есть четкое соединение и очень просто подключается)

    <?php
$steamauth['apikey'] = APIKEY; // Your Steam WebAPI-Key found at http://steamcommunity.com/dev/apikey
$steamauth['domainname'] = WEBSITE; // The main URL of your website displayed in the login page
$steamauth['logoutpage'] = WEBSITE; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
$steamauth['loginpage'] = WEBSITE; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

// System stuff
if (empty($steamauth['apikey'])) {die("<div style='display: block; width: 100%; background-color: red; text-align: center;'>SteamAuth:<br>Please supply an API-Key!<br>Find this in steamauth/SteamConfig.php, Find the '<b>\$steamauth['apikey']</b>' Array. </div>");}
if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];}
if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];}
if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];}

$steamid=mysqli_connect("","","","");
$steamid->set_charset("utf8");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($steamid, "SELECT * FROM panel_admins");

if (!$result) {
    printf("Error: %s\n", mysqli_error($steamid));
    exit();
}

echo "";

while ($row = mysqli_fetch_array($result)) {

$allowed_ids = [
    '"' . $row['steamid'] . '"',
];

}

mysqli_close($steamid);
?>

Но, с другой стороны, если у меня есть такой код, я могу войти без проблем

<?php
$steamauth['apikey'] = APIKEY; // Your Steam WebAPI-Key found at http://steamcommunity.com/dev/apikey
$steamauth['domainname'] = WEBSITE; // The main URL of your website displayed in the login page
$steamauth['logoutpage'] = WEBSITE; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
$steamauth['loginpage'] = WEBSITE; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

// System stuff
if (empty($steamauth['apikey'])) {die("<div style='display: block; width: 100%; background-color: red; text-align: center;'>SteamAuth:<br>Please supply an API-Key!<br>Find this in steamauth/SteamConfig.php, Find the '<b>\$steamauth['apikey']</b>' Array. </div>");}
if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];}
if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];}
if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];}

// allow only these ids
$allowed_ids = [
    'steamid64here',
];
?>

Может быть, код не хорош или что-то в этом роде. Я использую PHP 5.6! Что я хочу с помощью этого кода? Я хочу, чтобы в паровой колонне он схватил steamid64 и положил туда.

Теги:
mysqli

1 ответ

1
Лучший ответ

Вы переписываете значение $allowed_ids в цикле while в каждом проходе.

Попробуйте код ниже:

   $allowed_ids = array(); // initializing array
   while ($row = mysqli_fetch_array($result)) {
         $allowed_ids[] = $row['steamid'] ;// inserting elements into the array
   }
  • 0
    это сработало, спасибо
  • 0
    Добро пожаловать. Пожалуйста, посмотрите, если вы можете поднять ответ.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню