1

I am working the first time with mysqli prepare. Now I would like to handle the errors. I tried this:

$sql = $db->prepare( "SELECT * FROM `myTable` WHERE `myColumn` = ?" );
if ( $sql && $sql->bind_param("s", $value = 1) && $sql->execute() ) {
        
    $result = $sql->get_result();
            
    while ($zeile = $result->fetch_object()) {
        // ...
    }
    
    $sql->close();
        
} else {
    echo $sql->error;
    echo $db->error;
}

$db->close();

This works fine ! For example: If I modify the sql syntax (wrong table name, wrong column name, ...) I get correctly the $db->error.

But If the sql syntax is correct and I modify the $sql->bind_param like this:

$sql->bind_param("X", $value = 1)

I get no $sql->error and no $db->error. Where is my mistake?

Trombone0904
  • 4,132
  • 8
  • 51
  • 104

0 Answers0