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

<small id='NR8j4'></small><noframes id='NR8j4'>

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

        <tfoot id='NR8j4'></tfoot>

        Mysqli更新拋出調用成員函數bind_param()錯誤

        Mysqli update throwing Call to a member function bind_param() error(Mysqli更新拋出調用成員函數bind_param()錯誤)

        <small id='1PHI6'></small><noframes id='1PHI6'>

        • <bdo id='1PHI6'></bdo><ul id='1PHI6'></ul>
              <tbody id='1PHI6'></tbody>
            <tfoot id='1PHI6'></tfoot>
            <legend id='1PHI6'><style id='1PHI6'><dir id='1PHI6'><q id='1PHI6'></q></dir></style></legend>

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

                  本文介紹了Mysqli更新拋出調用成員函數bind_param()錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個 70/80 字段表單,我需要將其插入到表中,因此我不是手動創建一個巨大的插入語句,而是首先根據表單中輸入的名稱在我的數據庫中創建了一個表,這里是代碼我用來創建/更改表格

                  I have a 70/80 field form that I need to insert into a table so instead of manually creating one huge insert statement I firstly have created a table in my db from the names of the inputs in the form here is the code that I use to create/alter the table

                  function createTable($array, $memberMysqli)
                  {
                     foreach ($array as $key => $value)
                     {
                              //echo "<p>Key: ".$key." => Value: ".$value . "</p>";
                              $query = "ALTER TABLE questionnaire ADD ".$key."  text";
                  
                              if($stmt = $memberMysqli->prepare($query))
                              {
                                  $success = $stmt->execute();
                              }
                     }
                           echo "<h1>Array count: ". count($array) ."</h1>" ;
                  }
                  

                  這很好用并且完全按照我想要的方式改變了表格.現在要插入表單值來執行此操作,我執行一個基本的單字段插入存儲行的 id,然后循環更新該行的所有后期變量.這是我的代碼:

                  This works fine and altered the table exactly how I wanted it. Now to insert the form values to do this I do a basic one field insert store the id of the row and then have loop all the post variables updating that row. Here is my code for that:

                  $stmt = $memberMysqli->prepare("INSERT INTO questionnaire(userid) VALUES (?)");
                  
                  $stmt->bind_param('s', $_POST['userid']);
                  $stmt->execute();
                  $rowid = $stmt->insert_id;
                  $stmt->close();
                  
                  $memberMysqli->autocommit(FALSE);
                  
                  function updateColumn($memberMysqli, $query, $uid, $value) 
                  {
                      if ($value) 
                      {
                          $stmt = $memberMysqli->prepare($query);
                          //Throws bind param error here
                          $stmt->bind_param("ss", $value, $uid);
                          $stmt->execute();
                      }
                  }
                  
                  function loopInputs($array, $memberMysqli, $rowid)
                  {
                       foreach ($array as $key => $formvalue)
                       {
                          var_dump($key);
                          updateColumn($memberMysqli, "UPDATE questionnaire SET $key = ? WHERE id = ?", $rowid, $formvalue);
                       }
                  }
                  
                  loopInputs($_POST, $memberMysqli, $rowid);
                  
                  $memberMysqli->commit();
                  $memberMysqli->close();
                  

                  這會引發綁定參數錯誤,我不知道為什么.

                  This throws a bind param error and I have no idea why.

                  推薦答案

                  O,讓我們嘗試一個規范的答案.

                  O, let's try a canonical answer.

                  調用成員函數(或期望參數1為mysqli_result,布爾值給定用于程序風格)本身不是錯誤,而只是一個癥狀,對于其他一些問題.
                  這個錯誤消息意味著沒有在應該創建的地方創建對象.

                  Call to a member function (or expects parameter 1 to be mysqli_result, boolean given for the procedural style) is not an error itself but just a symptom, for some other problem.
                  This very error message means that no object was created where should.

                  因此 - 創建 $stmt 對象時出現問題.
                  很可能是查詢有問題.因此,我們需要跟蹤該錯誤.

                  So - there was a problem with creating an $stmt object.
                  Most likely it's a problem with the query. So, we need to track that error down.

                  除非明確詢問,否則 Mysqli 不會告訴您發生了什么.因此,您必須始終檢查與服務器交互的每個 mysqli 函數的結果,如果結果為 FALSE - 檢查 $mysqli->error.

                  Mysqli won't tell you what's going on unless asked explicitly. So, you have to always check the result of every mysqli function interacting with server and if result is FALSE - check $mysqli->error.

                  將 mysqli 錯誤消息轉換為 PHP 錯誤也很重要,讓它根據站點范圍的錯誤報告設置進行處理.

                  It is also very important to convert mysqli error message into PHP error, to let it go according site-wide error reporting settings.

                  如果您在整個應用程序代碼中使用 mysqli_query() 而不將其封裝到某個輔助類中,trigger_error() 是引發 PHP 錯誤的好方法,因為它還會告訴您文件和發生錯誤的行號

                  If you are using mysqli_query() all over the application code without encapsulating it into some helper class, trigger_error() is a good way to raise a PHP error, as it will tell you also the file and the line number where error occurred

                  因此,您所有的prepare()、execute() 和query() 調用都必須這樣編寫:

                  So, all your prepare(), execute() and query() calls have to be written this way:

                  $stmt = $mysqli->prepare($query) or trigger_error($mysqli->error."[$query]");
                  

                  或程序風格

                  $res = mysqli_query($mysqli,$query) or trigger_error(mysqli_error($mysqli)."[$query]");
                  

                  在你所有的腳本中
                  從那時起,您將被告知原因,即未創建對象的原因.(如果你對這個 or 語法感到好奇,我已經在這里解釋過)請注意,錯誤消息中還包含查詢,讓您可以直觀地檢查它并在另一個環境中進行測試.

                  in all your scripts
                  and since then you will be notified of the reason, why the object weren't created. (If you're curious of this or syntax, I've explained it here) Note that query also included in the error message, to let you inspect it visually and test in another environment.

                  但是,如果您將查詢封裝到某個類中,觸發器錯誤中的文件和行將毫無用處,因為它們將指向調用本身,而不是導致某些問題的應用程序代碼.所以,在運行封裝的mysqli命令時,還得用另一種方式:

                  However, if you're encapsulating your query into some class, file and line from trigger error will be quite useless as they will point to the call itself, not the application code that caused certain problem. So, when running mysqli commands encapsulated, another way have to be used:

                  $result = $mysqli->query($sql);
                  if (!$result) {
                      throw new Exception($mysqli->error." [$query]");
                  }
                  

                  as Exception 將為您提供堆棧跟蹤,它將引導您找到調用錯誤查詢的位置.

                  as Exception will provide you with a stack trace, which will lead you the the place from which an erroneous query were called.

                  請注意,您必須能夠看到一般的 PHP 錯誤.在實時站點上,您必須查看錯誤日志,因此設置必須

                  Note that you have to be able to see PHP errors in general. On a live site you have to peek into error logs, so, settings have to be

                  error_reporting(E_ALL);
                  ini_set('display_errors',0);
                  ini_set('log_errors',1);
                  

                  在本地開發服務器上,在屏幕上出錯是可以的:

                  while on a local development server it's all right to make errors on screen:

                  error_reporting(E_ALL);
                  ini_set('display_errors',1);
                  

                  當然,您永遠不應該在語句前使用錯誤抑制運算符 (@).

                  and of course you should never ever use error suppression operator (@) in front of your statements.

                  這篇關于Mysqli更新拋出調用成員函數bind_param()錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  store_result() and get_result() in mysql returns false(mysql 中的 store_result() 和 get_result() 返回 false)
                  Call to undefined function mysqli_result::num_rows()(調用未定義的函數 mysqli_result::num_rows())
                  PHP Prepared Statement Problems(PHP 準備好的語句問題)
                  mysqli_fetch_array returning only one result(mysqli_fetch_array 只返回一個結果)
                  PHP MySQLi Multiple Inserts(PHP MySQLi 多次插入)
                  How do I make sure that values from MySQL keep their type in PHP?(如何確保 MySQL 中的值在 PHP 中保持其類型?)

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

                      • <legend id='BG20F'><style id='BG20F'><dir id='BG20F'><q id='BG20F'></q></dir></style></legend>

                        <small id='BG20F'></small><noframes id='BG20F'>

                          • <tfoot id='BG20F'></tfoot>
                            主站蜘蛛池模板: 防爆型气象站_农业气象站_校园气象站_农业四情监测系统「山东万象环境科技有限公司」 | 座椅式升降机_无障碍升降平台_残疾人升降平台-南京明顺机械设备有限公司 | 学叉车培训|叉车证报名|叉车查询|叉车证怎么考-工程机械培训网 | 重庆网站建设,重庆网站设计,重庆网站制作,重庆seo,重庆做网站,重庆seo,重庆公众号运营,重庆小程序开发 | LNG鹤管_内浮盘价格,上装鹤管,装车撬厂家-连云港赛威特机械 | 嘉兴泰东园林景观工程有限公司_花箱护栏 | 北京易通慧公司从事北京网站优化,北京网络推广、网站建设一站式服务商-北京网站优化公司 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 预制直埋蒸汽保温管-直埋管道-聚氨酯发泡保温管厂家 - 唐山市吉祥保温工贸有限公司 | 耐磨焊丝,堆焊焊丝,耐磨药芯焊丝,碳化钨焊丝-北京耐默公司 | 喷砂机厂家_自动除锈抛丸机价格-成都泰盛吉自动化喷砂设备 | 诚暄电子公司首页-线路板打样,pcb线路板打样加工制作厂家 | 广州展台特装搭建商|特装展位设计搭建|展会特装搭建|特装展台制作设计|展览特装公司 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 高考志愿规划师_高考规划师_高考培训师_高报师_升学规划师_高考志愿规划师培训认证机构「向阳生涯」 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 大连海岛旅游网>>大连旅游,大连海岛游,旅游景点攻略,海岛旅游官网 | 「安徽双凯」自动售货机-无人售货机-成人用品-自动饮料食品零食售货机 | 希望影视-高清影视vip热播电影电视剧免费在线抢先看 | PCB设计,PCB抄板,电路板打样,PCBA加工-深圳市宏力捷电子有限公司 | 东莞螺丝|东莞螺丝厂|东莞不锈钢螺丝|东莞组合螺丝|东莞精密螺丝厂家-东莞利浩五金专业紧固件厂家 | 阿尔法-MDR2000无转子硫化仪-STM566 SATRA拉力试验机-青岛阿尔法仪器有限公司 | 开云(中国)Kaiyun·官方网站-登录入口 | 氧氮氢联合测定仪-联测仪-氧氮氢元素分析仪-江苏品彦光电 | 智能家居全屋智能系统多少钱一套-小米全套价格、装修方案 | 上海佳武自动化科技有限公司| 金属检测机_金属分离器_检针验针机_食品药品金属检探测仪器-广东善安科技 | 桨叶搅拌机_螺旋挤压/方盒旋切造粒机厂家-无锡市鸿诚输送机械有限公司 | 锡膏喷印机-全自动涂覆机厂家-全自动点胶机-视觉点胶机-深圳市博明智控科技有限公司 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 沟盖板_复合沟盖板厂_电力盖板_树脂雨水篦子-淄博拜斯特 | 专业广州网站建设,微信小程序开发,一物一码和NFC应用开发、物联网、外贸商城、定制系统和APP开发【致茂网络】 | 反渗透水处理设备|工业零排放|水厂设备|软化水设备|海南净水设备--海南水处理设备厂家 | 天津市能谱科技有限公司-专业的红外光谱仪_红外测油仪_紫外测油仪_红外制样附件_傅里叶红外光谱技术生产服务厂商 | 涡轮流量计_LWGY智能气体液体电池供电计量表-金湖凯铭仪表有限公司 | 成都竞价托管_抖音代运营_网站建设_成都SEM外包-成都智网创联网络科技有限公司 | 【直乐】河北石家庄脊柱侧弯医院_治疗椎间盘突出哪家医院好_骨科脊柱外科专业医院_治疗抽动症/关节病骨伤权威医院|排行-直乐矫形中医医院 | 高压直流电源_特种变压器_变压器铁芯-希恩变压器定制厂家 | 短信通106短信接口验证码接口群发平台_国际短信接口验证码接口群发平台-速度网络有限公司 | 体检车_移动CT车_CT检查车_CT车_深圳市艾克瑞电气有限公司移动CT体检车厂家-深圳市艾克瑞电气有限公司 |