致命错误:在非对象上调用成员函数 prepare() [英] Fatal error: Call to a member function prepare() on a non-object in

查看:20
本文介绍了致命错误:在非对象上调用成员函数 prepare()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我必须将发送器信息构建到 php 文件以在登录页面时发送到登录页面的方式

this is how I have to build the transmitters infomation on to a php file to send to login page when it is

<form action="http://,,,.dk/activate_updater.php" method="post" name="formular" onsubmit="return validerform ()">
                                 <table border="0">
                                     <tr>
                                         <td id="tb-w_a"><p>Kategori</p></td>
                                         <td>:</td>
                                         <td>
                                         <select name="kategori">
                                         <?php
                                         $query = "SELECT id_katogori, navn FROM kategori";
                                         $result = $mysqli->query($query);
                                         while(list($id_katogori, $navn) = $result->fetch_row())
                                         {
                                             echo "<option value="$id_katogori">$navn</option>";  
                                         }
                                         ?>
                                         </select>
                                         </td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Djnavn</p></td>
                                         <td>:</td>
                                         <td><input type="text" name="djnavn"></td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Facebook</p></td>
                                         <td>:</td>
                                         <td><input type="text" name="facebook"></td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Pris</p></td>
                                         <td>:</td>
                                         <td><input type="text" name="pris"></td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Booking Email</p></td>
                                         <td>:</td>
                                         <td><input type="email" name="booking"></td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Mobil</p></td>
                                         <td>:</td>
                                         <td><input type="text" name="mobil"></td>
                                     </tr>
                                     <tr>
                                         <td id="tb-w_a"><p>Upload Profil</p></td>
                                         <td>:</td>
                                         <td><input type="file" name="profilbillede" /></td>
                                     </tr>
                                 </table>
                             <textarea name="profiltekst" style="width:500px; height:170px;"></textarea><br />
                             <input type="submit" value="Godkend brugere" name="godkendt-brugere">
                         </form>

所以新的页面文件是这样的,页面上有错误..

so the new page file is like this where there are errors on the page ..

<?php
     if($stmt = $mysqli->prepare('UPDATE `brugere` SET `rank`=2, `katogori`=?, `djnavn`=?, `profilbillede`=?, `profiltekst`=?, `facebook`=?, `pris`=?, `booking`=?, `mobil`=? WHERE `code`=?'))
     {

         $stmt->bind_param('iiiiiiiis', $katogori, $djnavn, $profilbillede, $profiltekst, $facebook, $pris, $booking, $mobil, $g_code);
         //fra input ting ting..
         $katogori = $_POST["kategori"];
         $djnavn = $_POST["djnavn"];
         $profilbillede = $_POST["profilbillede"];
         $profiltekst = $_POST["profiltekst"];
         $facebook = $_POST["facebook"];
         $pris = $_POST["pris"];
         $booking = $_POST["booking"];
         $mobil = $_POST["mobil"];
         $g_code = $_GET["code"];

         $stmt->execute();
         $stmt->close();
         header('http://....dk/ (...));
     }
     else
     {
         echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
     }
 ?>

但是当它出现在文件/页面上时会这样说......

but when it comes onto the file / page says it like this ...

致命错误:在第 2 行的/home/jesperbo/public_html/....dk/activate_updater.php 中的非对象上调用成员函数 prepare()

就是这样写的

if($stmt = $mysqli->prepare('UPDATE `brugere` SET `rank`=2, `katogori`=?, `djnavn`=?, `profilbillede`=?, `profiltekst`=?, `facebook`=?, `pris`=?, `booking`=?, `mobil`=? WHERE `code`=?'))

我不是最能看到错误的人,但如果你看到我不必要的错误,因为它不会出现在数据库中,那就太好了

希望你能帮我解决这个问题!

推荐答案

发生这种情况是因为 $mysqli 不是您认为的对象.'没有正确实例化 MySQLi 类,或者它没有建立连接.执行 var_dump($mysqli) 以获取有关问题的更多信息.

This is happening because $mysqli isn't the object you think it is. Either you didn't instantiate the MySQLi class properly, or it didn't make a connection. Do a var_dump($mysqli) to get more info as to what's going wrong.

这篇关于致命错误:在非对象上调用成员函数 prepare()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆