-2

I've been getting one warning and one fatal error when trying to run the execute() command. I can't seem to find the error at my stm->execute();

Here are my errors:

Warning: mysqli_stmt::bind_param(): Invalid type or no types specified in C:\xampp\htdocs\library\admin-reg.php on line 20

Fatal error: Call to a member function execute() on boolean in C:\xampp\htdocs\library\admin-reg.php on line 33

Then this is a snippet of my code.

 <?php
                                                #CONNECTION    
    require 'dbcon.php';

                                                #INPUT CONTAINERS
    $ACTIVATION_CODE=$USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE='';

                                                #ERROR CONTAINERS
    $USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE=$USER_TYPE='';

                                                #CONNECTION/QUERY#
    $connection = mysqli_connect('localhost','root','','library_system') or die(mysqli_error());    
    $stm = $mysli_link->prepare("INSERT INTO users (username,password,first_name,middle_name,last_name,address,contact_no,email,activation_code) values(?,?,?,?,?,?,?,?,?)");
    $stm = $stm->bind_param($USERNAME,$PASSWORD,$FIRST_NAME,$MIDDLE_NAME,$LAST_NAME,$ADDRESS,$CONTACT_NO,$EMAIL,$ACTIVATION_CODE);
                                                #VERIFICATION SCRIPT
    IF(isset($_POST['register'])){
        $USERNAME = trim(mysqli_real_escape_string($connection,$_POST['username']));
        $PASSWORD = trim(mysqli_real_escape_string($connection,password_hash($_POST['password'],PASSWORD_DEFAULT)));
        $EMAIL = trim(mysqli_real_escape_string($connection,$_POST['email']));
        $FIRST_NAME = mysqli_real_escape_string($connection,$_POST['first_name']);
        $MIDDLE_NAME = mysqli_real_escape_string($connection,$_POST['middle_name']);
        $LAST_NAME = mysqli_real_escape_string($connection,$_POST['last_name']);
        $CONTACT_NO = trim(mysqli_real_escape_string($connection,$_POST['contact_no']));
        $ADDRESS = mysqli_real_escape_string($connection,$_POST['address']);            
        $ACTIVATION_CODE = md5($USERNAME.(rand(0,1000)));
        $USER_TYPE = "ADMIN";
        $stm->execute();                                            

    }

?>

Hope you can help me.

Jio M.
  • 114
  • 1
  • 7

1 Answers1

0

Is this a typo, or you need to correct that? Correct mysli to mysqli

$stm = $mysli_link->prepare("INSERT....

Also, bind_param accepts one more parameter types, which is the string with one or more characters defined as per information below. This parameter is required if any of the parameters size exceeds max_allowed_packet.

The types is defined as follows:- types A string that contains one or more characters which specify the types for the corresponding bind variables:

Type specification chars Character Description i corresponding variable has type integer d corresponding variable has type double s corresponding variable has type string b corresponding variable is a blob and will be sent in packets

So concatenate each letter for variable types in sequence

Aditya
  • 861
  • 5
  • 8