Evan Arends
Evan Arends

Reputation: 69

Number of elements in type definition string doesn't match number of bind variables

I keep getting this error in my php file .. Warning: mysqli_stmt_bind_param() [function.mysqli-stmt-bind-param]: Number of elements in type definition string doesn't match number of bind variables in ... on line 17 Heres is my code - I am trying to read everything from this table and store each column such as the username, or obo into an array, could be one whole array, or indiviudal ones for each Thanks

<?php
    $con = mysqli_connect("*****", "****", "***", "***");

    $username = $_POST["username"];
    $title = $_POST["title"];
    $description = $_POST["description"];
    $location = $_POST["location"];
    $cost = $_POST["cost"];
    $obo = $_POST["obo"];
    $dimmension = $_POST["dimmension"];
    $phone = $_POST["phone"];
    $email = $_POST["email"];
    $image = $_POST["image"];
    $image2 = $_POST["image2"];

    $statement = mysqli_prepare($con, "SELECT username,title,description,location,cost,obo,dimmension,phone,email,image,image2 FROM Postings");
    mysqli_stmt_bind_param($statement, $username,$title,$description,$location,$cost,$obo,$dimmension,$phone,$email,$image,$image2);
    mysqli_stmt_execute($statement);

    mysqli_stmt_store_result($statement);
    mysqli_stmt_bind_result($statement, $username,$title,$description,$location,$cost,$obo,$dimmension,$phone,$email,$image,$image2);

    $response = array();

    while(mysqli_stmt_fetch($statement)){  
        $response[] = $username;
    }

    $response["success"] = true; 
    #echo json_encode($respond);
    echo json_encode($response);
?>

Heres a picture of my php my admin table

enter image description here

Upvotes: 0

Views: 217

Answers (1)

Harish Kamboj
Harish Kamboj

Reputation: 907

You are calling Select statement and not binding anything. Remove this line

mysqli_stmt_bind_param($statement, $username,$title,$description,$location,$cost,$obo,$dimmension,$phone,$email,$image,$image2);

and code will work properly. Good luck.

Upvotes: 2

Related Questions