普通网友 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.

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

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效