E
E
Egor Tregubenko2016-05-06 23:50:17
PHP
Egor Tregubenko, 2016-05-06 23:50:17

Warning: mysql_fetch_array(): why?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\OpenServer\domains\php\show_users.php on
line mysql something is wrong. tell? here is the code

<?php

require_once 'scripts/app_config.php';
require_once 'scripts/database_connection.php';

//Создание инструкции select
$select_users = "SELECT user_id, first_name, last_name, email" . "FROM users";

//Запусук запроса

$result = mysql_query($select_users);

?>


<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Получение пльзователей</title>
    <link rel="stylesheet" href="css/phpMM.css">

    <script type="javascript">
        function delete_user(user_id) {
            if (confirm("Вы уверены в своем выборе?" + "\nВернуть его уже не получиться")) {
                window.location = "delete_user.php?user_id=" + user_id;
            }
        }
    </script>
</head>
<body>
<div class="header"><h1>ПРОШАРИВАНИЕ 10</h1></div>
<div class="example">Пользователи</div>
<div class="content">
    <ul>
        <?php
        while ($user = mysql_fetch_array($result)) {
            $user_row = sprintf(
                "<li><a href='show_user.php?user_id=%d'> %s %s </a> " . "(<a href='mailto: %s'>%s</a>)" .
                "<a href='javascript:delete_user(%d);'><img class='delete_user' src='phpMM/images/delete.png'" . "width='15' /></a></li>" ,
                $user['user_id'], $user['first_name'], $user['last_name'], $user['email'], $user['user_id']);

            echo $user_row;
        }
        ?>
    </ul>

</div>
<div id="footer"></div>
</body>
</html>

i.e. on line 37 it is while ($user = mysql_fetch_array($result)) {

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Tregubenko, 2016-05-07
@Sinecuraweb

in general, the solution lay in
and also confused with the number

%s

ps I didn’t fully understand the toaster, (why it’s impossible to mark a comment to the description as a decision) so I brought it here if it’s useful to anyone in the future
Thank you all!

U
Uwe_Boll, 2016-05-07
@Uwe_Boll

I fully agree with DevMan
's answer And now, in the case, you have an error in the request, and therefore false flies to line 37

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question