dongmei9961 2015-08-27 13:05
浏览 93

mysql_fetch_array没有返回任何内容

Can someone please help with below query. The code mentioned below is not returning FirstName and LastName. Why?

Cheers, Akhil G

<?php 

        $username = mysql_real_escape_string($_GET['user']);
        $firstname ="" ;
        $lastname ="";
            if (ctype_alnum($username))
            {
                //check user exist

                $check = mysql_query("SELECT username, first_name, last_name FROM syn where username = '$username'");
                if (mysql_num_rows($check) === 1)
                {
                    $get = mysql_fetch_array($check);
                    $username = $get['username'];
                    $firstname = $get['first_name'];
                    $lastname = $get['last_name'];
                } else 
                echo "<h2> User Does Not Exist ! </h2>";
                exit();
            }   
?>
  • 写回答

3条回答 默认 最新

  • dtv8189 2015-08-27 14:53
    关注

    you are using the wrong fetch function

    $get = mysql_fetch_array($check);
    

    stored data in numbered positions in the array, so the returned data is stored in $get[0], $get[1] and $get[2].

    you can see the contents by using print_r($get);

    Instead use

    $get = mysql_fetch_assoc($check);
    

    this stores the data in the associated array you require.

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端