Uncaught Error: Call to undefined function bind_param() in C:\wamp64\www\users\action.php on line 24

Any body can help me to find out this error

 Uncaught Error: Call to undefined function bind_param() in C:\wamp64\www\users\action.php on line 24


<?php

require_once 'config.php';

 if(isset($_POST['action']) && $_POST['action'] == 'register')

 {

    $name=check_data($_POST['name']);

    $uname=check_data($_POST['uname']);

    $email=check_data($_POST['email']);

    $pass=check_data($_POST['pass']);

    $cpass=check_data($_POST['cpass']);

    $pass=sha1($pass);

    $cpass=sha1($cpass);

    $created=date('d-m-y');

    if($pass!=$cpass)

    {

       echo "Password did not matched.";

       exit();

    }

    else

     {

         $sql=$conn->prepare("SELECT username,email FROM users WHERE username=OR email=?");

         $sql->bind_param("ss",$uname,$email); //here show error

         $sql->execute();

         $result=$sql->get_result();

         $row=$result->fetch_array(MYSQLI_ASSOC);

         //check username availability

         if($row['username']==$uname)

         {

            echo "Username not availabe, Try with different username.";

         }

         //check email availability/exist

         elseif($row['email']==$email)

         {

            echo "Email address already registered.";

         }

         else

         {

            $stmt=$conn->prepare("INSERT INTO users (name,username,email,pass,created) VALUES (?,?,?,?,?)");

            $stmt->bind_param("sssss",$name,$uname,$email,$pass,$created);

            if($stmt->execute())

            {

               echo "Register Successful. Login now!";

            }

            else

            {

               echo "Something went wrong. try again!";

            }

         }

      }

 }

//input data space removing/special character removing

 function check_data($data)

 {

    $data=trim($data);

    $data=stripslashes($data);

    $data=htmlspecialchars($data);

 }

?>


Answers 1

  • I checked your code in my local system its working fine may be check your config.php file if your mysql username password is wrong than this error also occur. I also faced this.



Related Articles