pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='D2iOW'></bdo><ul id='D2iOW'></ul>

    1. <small id='D2iOW'></small><noframes id='D2iOW'>

      <tfoot id='D2iOW'></tfoot>

      <i id='D2iOW'><tr id='D2iOW'><dt id='D2iOW'><q id='D2iOW'><span id='D2iOW'><b id='D2iOW'><form id='D2iOW'><ins id='D2iOW'></ins><ul id='D2iOW'></ul><sub id='D2iOW'></sub></form><legend id='D2iOW'></legend><bdo id='D2iOW'><pre id='D2iOW'><center id='D2iOW'></center></pre></bdo></b><th id='D2iOW'></th></span></q></dt></tr></i><div class="g2kisia" id='D2iOW'><tfoot id='D2iOW'></tfoot><dl id='D2iOW'><fieldset id='D2iOW'></fieldset></dl></div>
      <legend id='D2iOW'><style id='D2iOW'><dir id='D2iOW'><q id='D2iOW'></q></dir></style></legend>

        mysqli 代碼和 call_user_func_array() 中出現(xiàn)的錯誤

        Errors appearing in mysqli code and call_user_func_array()(mysqli 代碼和 call_user_func_array() 中出現(xiàn)的錯誤)

            <tfoot id='x7TOi'></tfoot>
                <tbody id='x7TOi'></tbody>
              <legend id='x7TOi'><style id='x7TOi'><dir id='x7TOi'><q id='x7TOi'></q></dir></style></legend>
                <bdo id='x7TOi'></bdo><ul id='x7TOi'></ul>
              • <i id='x7TOi'><tr id='x7TOi'><dt id='x7TOi'><q id='x7TOi'><span id='x7TOi'><b id='x7TOi'><form id='x7TOi'><ins id='x7TOi'></ins><ul id='x7TOi'></ul><sub id='x7TOi'></sub></form><legend id='x7TOi'></legend><bdo id='x7TOi'><pre id='x7TOi'><center id='x7TOi'></center></pre></bdo></b><th id='x7TOi'></th></span></q></dt></tr></i><div class="00ik2wk" id='x7TOi'><tfoot id='x7TOi'></tfoot><dl id='x7TOi'><fieldset id='x7TOi'></fieldset></dl></div>
              • <small id='x7TOi'></small><noframes id='x7TOi'>

                  本文介紹了mysqli 代碼和 call_user_func_array() 中出現(xiàn)的錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我在嘗試使用 mysqli 創(chuàng)建動態(tài) where 子句時遇到不少錯誤:

                  I am getting quite a few errors when trying to create a dynamic where clause using mysqli:

                  警告:mysqli_stmt::bind_param() 的參數(shù) 2 預(yù)期為參考,在第 319 行中給出的值

                  Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in ... on line 319

                  警告:mysqli_stmt::execute(): (HY000/2031): 沒有提供數(shù)據(jù)第 328 行的準(zhǔn)備語句中的參數(shù)

                  Warning: mysqli_stmt::execute(): (HY000/2031): No data supplied for parameters in prepared statement in ... on line 328

                  警告:mysqli_stmt::bind_result(): (HY000/2031): 未提供數(shù)據(jù)在第 331 行的準(zhǔn)備語句中的參數(shù)

                  Warning: mysqli_stmt::bind_result(): (HY000/2031): No data supplied for parameters in prepared statement in ... on line 331

                  警告:mysqli_stmt::store_result(): (HY000/2014): 命令超出同步;你現(xiàn)在不能在……第 332 行運行這個命令

                  Warning: mysqli_stmt::store_result(): (HY000/2014): Commands out of sync; you can't run this command now in ... on line 332

                  我猜想解決問題需要做一些改動,但是如果兩個下拉菜單中的一個不等于 All 或者兩者都不等于 全部然后出現(xiàn)錯誤.

                  Im guessing there is a little change that is needed to solve the problems but what happens is that if one of the two drop down menu's do not equal All or if both don't equal All then it comes up with the errors.

                  下面的代碼顯示了下拉菜單和后面的查詢(帶有動態(tài) where 子句),具體取決于所選的 n 個選項:

                  Below is the code display both the drop down menus and the query (with dynamic where clause) that follows depending n options selected:

                  HTML:

                  學(xué)生下拉菜單:

                  <select name="student" id="studentsDrop">
                  <option value="All">All</option>
                  <option value="11">John May</option>
                  <option value="23">Chris Park</option>
                  </select>
                  

                  問題編號下拉菜單

                  <select name="question" id="questionsDrop">
                  <option value="All">All</option>
                  <option value="123">1</option>
                  <option value="124">2</option>
                  <option value="125">3</option>
                  </select>
                  

                  PHP/MYSQLI:

                        function StudentAnswers()
                          {
                  
                  
                      /*BELOW IS THE QUERY WHERE I AM TRYING TO RETRIEVE DATA DEPENDING ON THE ASSESSMENT CHOSEN AND
                      THEN DEPENDING ON OPTIONS CHOSEN IN STUDENT AND QUESTION NUMBER DROP DOWN MENU */
                  
                          $selectedstudentanswerqry = "
                          SELECT
                          StudentAlias, StudentForename, StudentSurname, q.SessionId, QuestionNo, QuestionContent, o.OptionType, q.NoofAnswers, GROUP_CONCAT( DISTINCT Answer
                          ORDER BY Answer SEPARATOR ',' ) AS Answer, r.ReplyType, QuestionMarks, 
                          GROUP_CONCAT(DISTINCT StudentAnswer ORDER BY StudentAnswer SEPARATOR ',') AS StudentAnswer, ResponseTime, MouseClick, StudentMark
                          FROM Student s
                          INNER JOIN Student_Answer sa ON (s.StudentId = sa.StudentId)
                          INNER JOIN Student_Response sr ON (sa.StudentId = sr.StudentId)
                          INNER JOIN Question q ON (sa.QuestionId = q.QuestionId)
                          INNER JOIN Answer an ON q.QuestionId = an.QuestionId
                          LEFT JOIN Reply r ON q.ReplyId = r.ReplyId
                          LEFT JOIN Option_Table o ON q.OptionId = o.OptionId
                          ";
                  
                          // Initially empty
                          $where = array('q.SessionId = ?');
                          $parameters = array($_POST["session"]);
                          $parameterTypes = 'i';
                  
                          // Check whether a specific student was selected
                          if($_POST["student"] !== 'All') {
                              $where[] = 'sa.StudentId = ?';
                              $parameters[] =& $_POST["student"];
                              $parameterTypes .= 'i';
                          }
                  
                          // Check whether a specific question was selected
                          // NB: This is not an else if!
                          if($_POST["question"] !== 'All') {
                              $where[] = 'q.QuestionId = ?';
                              $parameters[] =& $_POST["question"];
                              $parameterTypes .= 'i';
                          }
                  
                          // If we added to $where in any of the conditionals, we need a WHERE clause in
                          // our query
                          if(!empty($where)) {
                              $selectedstudentanswerqry .= ' WHERE ' . implode(' AND ', $where);
                              global $mysqli;
                              $selectedstudentanswerstmt=$mysqli->prepare($selectedstudentanswerqry);
                              // You only need to call bind_param once
                                  call_user_func_array(array($selectedstudentanswerstmt, 'bind_param'),
                                  array_merge(array($parameterTypes), $parameters)); //LINE 319 ERROR 1
                          }
                  
                      //Add group by and order by clause to query
                          $selectedstudentanswerqry .= "
                            GROUP BY sa.StudentId, q.QuestionId
                            ORDER BY StudentAlias, q.SessionId, QuestionNo
                          ";
                  
                          // get result and assign variables (prefix with db)
                          $selectedstudentanswerstmt->execute(); //LINE 328 ERROR 2
                  
                      //bind database fields 
                  $selectedstudentanswerstmt->bind_result($detailsStudentAlias,$detailsStudentForename,$detailsStudentSurname,$detailsSessionId,$detailsQuestionNo, 
                          $detailsQuestonContent,$detailsOptionType,$detailsNoofAnswers,$detailsAnswer,$detailsReplyType,$detailsQuestionMarks,$detailsStudentAnswer,$detailsResponseTime,
                          $detailsMouseClick,$detailsStudentMark); //LINE 331 ERROR 3
                  
                      //store results retrieved
                          $selectedstudentanswerstmt->store_result(); //LINE 332 ERROR 4
                  
                      //count number of rows retrieved
                          $selectedstudentanswernum = $selectedstudentanswerstmt->num_rows();     
                  
                      //output query
                          echo "$selectedstudentanswerqry";
                  
                          }
                  
                          ?>
                  

                  這是一個演示: 演示

                  在演示中,從下拉菜單中選擇一個評估并提交.您將看到兩個下拉菜單.將它們都設(shè)置為 All 并提交,它將毫無問題地輸出查詢.在其中一個下拉菜單中選擇否,將 All 更改為特定的學(xué)生或問題,然后提交.現(xiàn)在你會看到錯誤

                  In demo select an assessment from drop down menu and submit. You will see the two drop down menus. Keep them both set as All and submit, it will output query with no problems. No in one of the drop down menus, change All to a specific student or question, then submit. Now you will see the errors

                  VAR 轉(zhuǎn)儲:

                  var_dump(array_merge(array($parameterTypes), $parameters))); 當(dāng)我選擇值為 31 的 session(評估)時的結(jié)果,學(xué)生編號值 40,問題編號值 81,和 WHERE CLAUSE WHERE q.SessionId = ?和 sa.StudentId = ?AND q.QuestionId = ?:

                  The result of the var_dump(array_merge(array($parameterTypes), $parameters))); when I chose session (assessment) with value 31, student number value 40, and question number value 81, AND WHERE CLAUSE WHERE q.SessionId = ? AND sa.StudentId = ? AND q.QuestionId = ?:

                  我得到這個輸出:array(4) { [0]=>string(3) "iii" [1]=>字符串(2)31"[2]=>字符串(2)40"[3]=>字符串(2) "81" }

                  推薦答案

                  這是一個棘手的情況,由 PHP 5.4 中的 call_user_func_array 行為改變引起(我必須假設(shè)):文檔

                  This is a sticky situation that is caused by changing of call_user_func_array behavior in PHP 5.4 (I have to assume): Documentation

                  盡管如此丑陋,它仍然可以這樣調(diào)用 bind_param:

                  As ugly as this is, it will work to call bind_param this way:

                  $selectedstudentanswerqry .= ' WHERE ' . implode(' AND ', $where);
                  global $mysqli;
                  $stmt =$mysqli->prepare($selectedstudentanswerqry);
                  
                  if (count($where) === 1) {
                      $stmt->bind_param($parameterTypes, $parameters[0]);
                  }
                  else if (count($where) === 2) {
                      $stmt->bind_param($parameterTypes, $parameters[0], $parameters[1]);
                  }
                  else if (count($where) === 3) {
                      $stmt->bind_param($parameterTypes, $parameters[0], $parameters[1],
                         $parameters[2]);
                  }
                  

                  我和你一樣討厭這個.我建議從 mysqli 切換到 PDO,它以更好的方式處理可變參數(shù)(在我看來,它的語法總體上更出色):

                  I hate this as much as you probably do. I suggest switching from mysqli to PDO which handles variable parameters in a much nicer fashion (and has superior syntax in general, in my opinion):

                  $pdo = new PDO('mysql:host=localhost', 'username', 'password');
                  $stmt = $pdo->prepare($selectedstudentanswerqry);
                  $stmt->execute($parameters);
                  $selectedstudentanswernum = $stmt->rowCount();
                  

                  這篇關(guān)于mysqli 代碼和 call_user_func_array() 中出現(xiàn)的錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調(diào)用未定義的函數(shù) mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準(zhǔn)備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結(jié)果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)
                  • <bdo id='Ris09'></bdo><ul id='Ris09'></ul>
                    • <small id='Ris09'></small><noframes id='Ris09'>

                      <tfoot id='Ris09'></tfoot>
                    • <i id='Ris09'><tr id='Ris09'><dt id='Ris09'><q id='Ris09'><span id='Ris09'><b id='Ris09'><form id='Ris09'><ins id='Ris09'></ins><ul id='Ris09'></ul><sub id='Ris09'></sub></form><legend id='Ris09'></legend><bdo id='Ris09'><pre id='Ris09'><center id='Ris09'></center></pre></bdo></b><th id='Ris09'></th></span></q></dt></tr></i><div class="icsysse" id='Ris09'><tfoot id='Ris09'></tfoot><dl id='Ris09'><fieldset id='Ris09'></fieldset></dl></div>

                      <legend id='Ris09'><style id='Ris09'><dir id='Ris09'><q id='Ris09'></q></dir></style></legend>
                        <tbody id='Ris09'></tbody>

                            主站蜘蛛池模板: 萃取箱-萃取槽-PVC萃取箱厂家-混合澄清槽- 杭州南方化工设备 | 酒糟烘干机-豆渣烘干机-薯渣烘干机-糟渣烘干设备厂家-焦作市真节能环保设备科技有限公司 | 一体化隔油提升设备-餐饮油水分离器-餐厨垃圾处理设备-隔油池-盐城金球环保产业发展有限公司 | 屏蔽服(500kv-超高压-特高压-电磁)-徐吉电气 | 圆周直径尺-小孔内视镜-纤维研磨刷-东莞市高腾达精密工具 | 交通气象站_能见度检测仪_路面状况监测站- 天合环境科技 | 100_150_200_250_300_350_400公斤压力空气压缩机-舰艇航天配套厂家 | 液压压力机,液压折弯机,液压剪板机,模锻液压机-鲁南新力机床有限公司 | 合景一建-无尘车间设计施工_食品医药洁净车间工程装修总承包公司 | 国产频谱分析仪-国产网络分析仪-上海坚融实业有限公司 | 求是网 - 思想建党 理论强党| 云南标线|昆明划线|道路标线|交通标线-就选云南云路施工公司-云南云路科技有限公司 | 臭氧灭菌箱-油桶加热箱-原料桶加热融化烘箱-南京腾阳干燥设备厂 臭氧发生器_臭氧消毒机 - 【同林品牌 实力厂家】 | 玻璃钢格栅盖板|玻璃钢盖板|玻璃钢格栅板|树篦子-长沙川皖玻璃钢制品有限公司 | 步入式高低温测试箱|海向仪器 | 健身器材-健身器材厂家专卖-上海七诚健身器材有限公司 | IWIS链条代理-ALPS耦合透镜-硅烷预处理剂-上海顶楚电子有限公司 lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 小型手持气象站-空气负氧离子监测站-多要素微气象传感器-山东天合环境科技有限公司 | 拉力测试机|材料拉伸试验机|电子拉力机价格|万能试验机厂家|苏州皖仪实验仪器有限公司 | 电池高低温试验箱-气态冲击箱-双层电池防爆箱|简户百科 | 雾度仪_雾度计_透光率雾度仪价格-三恩时(3nh)光电雾度仪厂家 | 吸污车_吸粪车_抽粪车_电动三轮吸粪车_真空吸污车_高压清洗吸污车-远大汽车制造有限公司 | 电动不锈钢套筒阀-球面偏置气动钟阀-三通换向阀止回阀-永嘉鸿宇阀门有限公司 | 泰安办公家具-泰安派格办公用品有限公司 | 我爱古诗词_古诗词名句赏析学习平台 | 小型铜米机-干式铜米机-杂线全自动铜米机-河南鑫世昌机械制造有限公司 | 聚合氯化铝-碱式氯化铝-聚合硫酸铁-聚氯化铝铁生产厂家多少钱一吨-聚丙烯酰胺价格_河南浩博净水材料有限公司 | 电磁流量计_智能防腐防爆管道式计量表-金湖凯铭仪表有限公司 | 丝杆升降机-不锈钢丝杆升降机-非标定制丝杆升降机厂家-山东鑫光减速机有限公司 | 交流伺服电机|直流伺服|伺服驱动器|伺服电机-深圳市华科星电气有限公司 | 北京普辉律师事务所官网_北京律师24小时免费咨询|法律咨询 | SEO网站优化,关键词排名优化,苏州网站推广-江苏森歌网络 | 上海橡胶接头_弹簧减震器_金属软接头厂家-上海淞江集团 | 依维柯自动挡房车,自行式国产改装房车,小型房车价格,中国十大房车品牌_南京拓锐斯特房车 - 南京拓锐斯特房车 | 耐高温风管_耐高温软管_食品级软管_吸尘管_钢丝软管_卫生级软管_塑料波纹管-东莞市鑫翔宇软管有限公司 | 热缩管切管机-超声波切带机-织带切带机-无纺布切布机-深圳市宸兴业科技有限公司 | 悬浮拼装地板_篮球场木地板翻新_运动木地板价格-上海越禾运动地板厂家 | 苏州西装定制-西服定制厂家-职业装定制厂家-尺品服饰西装定做公司 | 小型单室真空包装机,食品单室真空包装机-百科 | 不发火防静电金属骨料_无机磨石_水泥自流平_修补砂浆厂家「圣威特」 | 广州迈驰新GMP兽药包装机首页_药品包装机_中药散剂包装机 |