doushichi3678 2014-05-04 13:40
浏览 42
已采纳

php:没有从我的(预准备语句)查询得到结果

Can someone point out where the error is please? I run the below code, and instead of it populating the array, it gives me an empty result.

I have check the SQL in my database and it is running fine.

function fetchStatusDetails($cno, $randomPass)
{
    $mysqli = $this->_setDB (); // This sets up the DB connection.

        if ($stmt = $mysqli->prepare ( "SELECT created_main_menus,created_submenus,picked_a_header_image,uploaded_a_header_image,has_logo FROM " . $this->tableName . " WHERE random_password=? and CNO=? LIMIT 1" ))
        {


            /* bind parameters for markers */
            $stmt->bind_param ( "si", $randomPass,$cno );

            $stmt->execute ();

            $stmt->bind_result ( $main_menus,$sub_menus,$picked_header_img,$upped_header_img,$logo );

            $stmt->fetch ();

            if (! empty ( $main_menus ))
            {
                $array = array();

                $array['main_menus']            = $main_menus;
                $array['sub_menus']             = $sub_menus;
                $array['picked_header_img']     = $picked_header_img;
                $array['upped_header_img']      = $upped_header_img;
                $array['logo']                  = $logo;
                echo "*-*-".$array['upped_header_img']."*-*-";

                return $array;
            }
            else
            {echo "DATABASE ERROR 0090";
                return false;
            }

            /* close statement */
            $stmt->close ();
        }
  • 写回答

2条回答 默认 最新

  • doukekui0914 2014-05-04 14:04
    关注

    try if(isset($main_menus)) instead of if (! empty ( $main_menus ))

    all the best

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据