普通网友 2014-05-11 03:56
浏览 109
已采纳

致命错误:调用成员函数bind_param()

I am getting the following error message:

Fatal error: Call to a member function bind_param() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/ict136/aaregistration/register/register.php on line 89

Here is my code:

<?php include('header.php'); ?>


<!-- start of content -->
<div class="container">

    <form role="form" action="" method="POST">
          <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"><h3><center><strong>Member Registration</strong> </center></h3></div>
              <div class="col-md-4"> </div>
          </div>
          <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"> <input type="text"       required name="fullname"   id="fullname"                placeholder="enter full name"></div>
              <div class="col-md-4"> </div>
            </div>

              <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"> <input type="text"       required name="address"     id="fullname"               placeholder="enter address"></div>
              <div class="col-md-4"> </div>
            </div>

           <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"><input type="email"       required name="email"       id="exampleInputEmail1"     placeholder="Enter email"></div>
              <div class="col-md-4"> </div>
          </div>
            <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"> <input type="date"       required name="bday"        id="exampleInputDate1"              placeholder="(YYYY-MM-DD)"></div>
              <div class="col-md-4"> </div>
          </div>

           <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4"> <input type="password"   required name="password"    id="exampleInputPassword1"  placeholder="Password"></div>
              <div class="col-md-4"> </div>
          </div>
                   <div class="row">
              <div class="col-md-4"></div>
              <div class="col-md-4">  <button type="submit" name="submit" value="submit" class="btn btn-default">Submit</button></div>
              <div class="col-md-4"></div>
          </div
           <div class="row">
              <div class="col-md-4"> </div>
              <div class="col-md-4">
              <?php
                 if(isset($_POST['submit'])){
                 echo "Thank you for registering  ".$_POST['fullname']."!";


                 //assigning the values from the form to the variables after cleaning
                 $name=$_POST['fullname'];
                 $address=$_POST['address'];
                 $email=$_POST['email'];
                 $happybday=$_POST['bday'];
                 $pword=$_POST['password'];




                 //open a connection to the database
                 $con=mysqli_connect("localhost","root","","firstmatesales") ;

                //checking if it is successful

                if(mysqli_connect_errno())
                {
                //greater than 0 - has error

                echo "<br/>Error connecting to database hehehe";
                exit();
                }else
                         {
               //0 means false - no error
                echo "<br/>Well played! connected to database!";

                $sqlstmt="insert into firstmatesales(customername,customeraddress,customeremail,customerbirthday,password) values(?,?,?,?,?)";

                 //$name=$_POST['fullname'];
                 //$address=$_POST['address'];
                 //$email=$_POST['email'];
                //$happybday=$POST['bday'];
                 //$pword=$_POST['password'];


                $stmt=$con->prepare ($sqlstmt);
 <!--line 89--> $stmt->bind_param('sssss', $name, $address, $email, $happybday, $pword);
                $stmt->execute();                
                          }

                 }
                 else
                 {
                  echo "please register your information";
                  }
              ?>

              </div>
              <div class="col-md-4"> </div>
          </div>
    </form>

</div>   
<!-- end of content --> 

<?php include('footer.php'); ?>
  • 写回答

1条回答 默认 最新

  • doulu4203 2014-05-11 04:02
    关注

    you need to know something

    Call to a member function bind_param() on a non-object means that $stmt, which you're trying to call bind_param on, is not an object.

    Why is it not an object? Because $mysqli->prepare did not return an object. Why did it not return an object?

    So that means an error must have occurred. You should turn on error_reporting, which will probably tell you, or examine $mysqli->error(), which may tell you as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 FOR循环语句显示查询超过300S错误怎么办
  • ¥15 数电设计题 没有设计思路 不知道用什么芯片进行设计 求提供设计思路
  • ¥15 在动态多目标优化问题中,第一幅图展示的是问题DF6的相关定义和绘制的POS和POF图,请问图中公式PS(t)和PF(t)是如何推导的
  • ¥60 先数学建模,接着设计一种优化算法结合案例给出智能仓储四向穿梭车的调度计划
  • ¥15 Errno2:No such file or directory,在当前文件确实没有该图片,怎么解决?
  • ¥15 博世摄像头数据存储的问题(iscsi)
  • ¥15 如何实现对学生籍贯信息管理系统的选择排序
  • ¥15 写一个51单片机的时钟代码
  • ¥15 git clone报错
  • ¥15 3d-slicer超声造影动态图像导入报错