0

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

Evan Arends
  • 69
  • 1
  • 4
  • 1
    You aren't binding any parameters, so you don't need that statement. A bind parameter would be used for a statement such as: select title from postings where username = ? – David Aman Jul 20 '16 at 02:33
  • you actually don't need `mysqli_stmt_bind_param` for this statement. just remove that line and you should be fine. use that function for binding user input. – Jeff Puckett Jul 20 '16 at 02:33

1 Answers1

2

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.

Harish Kamboj
  • 887
  • 12
  • 32