1

我创建图像滑块。它必须使用用户名和密码才能运行。这是。

    <?
        include 'connect.php';
        $_session[user_login] = "zyxel";
        $_session[pass_login] = "12345";

    ?>
    <html>
    <head>
        <link rel="stylesheet" href="themes/default/default.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="themes/light/light.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="themes/dark/dark.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="lib/nivo-slider.css" type="text/css" media="screen" />
        <link rel="stylesheet" href="lib/style.css" type="text/css" media="screen" />
    </head>
    <body>
     <div class="slider-wrapper theme-default">
                <div id="slider" class="nivoSlider">
        <?php
                    $sql1 = "SELECT gload1,gload2,gload3,gload4,gload5 FROM member WHERE $_session[user_login] AND $_session[pass_login]";
                    $result1 = mysql_query($sql1);
                    $arry1 = mysql_fetch_array($result1);
                    $a = 0;         
                    $b = 1;
                    $c = 2;
                    $d = 3;
                    $e = 4;
                    $f = 5;
                    $g = 6;
                    $h = 7;
                    $i = 8;
                    $j = 9;
            if(empty($arry1)){
                exit();
                }
            else {
                $index = array_search(max($arry1),$arry1);

            if($index == $a){
                            echo "<img src=images/01/01.jpg>";
                            echo "<img src=images/01/02.jpg>";
                            echo "<img src=images/01/03.jpg>";
                            echo "<img src=images/01/04.jpg>";
                        }else if($index == $b){
                                echo "<img src=images/02/01.jpg>";
                                echo "<img src=images/02/02.jpg>";
                                echo "<img src=images/03/03.jpg>";
                                echo "<img src=images/04/04.jpg>";
                                }else if($index == $c){
                                    echo "<img src=images/03/01.jpg>";
                                    echo "<img src=images/03/02.jpg>";
                                    echo "<img src=images/03/03.jpg>";
                                    echo "<img src=images/03/04.jpg>";
                                    }else if($index == $d){
                                        echo "<img src=images/04/01.jpg>";
                                        echo "<img src=images/04/02.jpg>";
                                        echo "<img src=images/04/03.jpg>";
                                        echo "<img src=images/04/04.jpg>";
                                        }else {exit();
}
?>
</body>
</html>

错误是:警告:mysql_fetch_array():提供的参数不是第 21 行中的有效 MySQL 结果资源 [$arry1 = mysql_fetch_array($result1);]

我知道问题出在 SQL 中!在此之前,我使用 [SELECT .... FROM member WHERE mid = '001';] 并且它只是显示出来。 我该如何解决。

感谢您的任何回答。

4

2 回答 2

0

您的 SELECT 查询中的问题..您没有比较任何值。喜欢..

FROM member WHERE     $_session[user_login] AND     $_session[pass_login]
                  ^^^                           ^^^  

在这里你缺少列名,会话变量也必须是大写的后者......试试下面的查询。

$sql1 = "SELECT gload1,gload2,gload3,gload4,gload5 FROM member WHERE mid = '".$_SESSION['user_login']."' AND password = '".$_SESSION['pass_login']."'";


同样在会话变量的顶部声明是错误的,将其更改为

$_SESSION['user_login'] = "zyxel";
$_SESSION['pass_login'] = "12345";
于 2013-09-27T17:56:22.547 回答
0

There is a lot wrong here.

I would read the PHP Documentation before proceeding.

A few glaring issues are listed below:

Never store passwords in plain text. This is an assumption looking at the rest of your code.

$_SESSION; // a super global should always be capitalized.

Array keys:

$_SESSION['key'] = "value";

Escaping quotes

$foo['bar'] = "example";

echo "This is an " . $foo['bar'] . " of escaping quotes";
于 2013-09-27T18:23:19.710 回答