1

Here down a sample of my program:

$mysqli = new mysqli($db_host, $db_username, $db_password, $db_name);
if ($mysqli -> connect_error) {
    die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}

if ($stmt = $mysqli -> prepare("SELECT c_id, c_name, c_pic,o_name, c_location, c_address, PIN, c_phone, c_email, c_category, c_message FROM client_detail WHERE c_category = ? AND active='yes'")) {
    $stmt -> bind_param('s',$Data);
    $stmt -> execute();
    $stmt -> bind_result($c_id,$c_name,$c_pic,$o_name,$c_location,$c_address,$PIN,$c_phone,$c_email,$c_category,$c_message);
}

The problem arises when I am pass ? as agument while if I pass a concrete value or variable, the query is running.

If I skip the where the program also runs so why is the data is not bound to ??

tmarwen
  • 15,750
  • 5
  • 43
  • 62
  • This does appear to be the way to do it, and I don't see any obvious mistakes. Are you sure the bound parameter is correctly set? Make suer you're capturing errors from `mysqli`. [Turn on exceptions](http://stackoverflow.com/questions/23816633/mysqli-not-throwing-errors-why) to make them impossible to miss. – tadman Feb 24 '17 at 08:19
  • How are you checking that this code is not working & use [mysqli_error](http://php.net/manual/en/mysqli.error.php) so see error . – gaurav Feb 24 '17 at 08:57
  • I have used the follwing statement as I think the error on binding..... but no error is showing .... if(!$stmt->bind_param('s',$Data)){ printf("Errormessage: %s\n", $mysqli->error); } – Debraj Basu Feb 24 '17 at 09:11

0 Answers0