I decided to switch to mysqli, but in some things it is still not as strong as with the outdated dialect, because it has not yet fully understood the mechanics of this. Please help.

What did I do wrong here?

$db = new mysqli($hystbdserver,$hystbduser,$hystbdpassword,$hystbdname); $db->set_charset("utf8"); $add = $db->stmt_init(); $add->prepare("INSERT INTO hystsukategories (name,image,text) VALUES (?, ?, ?)"); $add->bind_param('sss',$name,$resize,$text); $name = $db->real_escape_string($name); $resize = $db->real_escape_string($resize); $text = $db->real_escape_string($text); $add->execute(); mysqli_close($db); 

gives such errors

Warning: mysqli_stmt :: bind_param () [mysqli-stmt.bind-param]: invalid object or resource mysqli_stmt in ##### on line #


Warning: mysqli_stmt :: execute () [mysqli-stmt.execute]: invalid object or resource; mysqli_stmt in ##### on line #

  • Well, which line exactly indicates the first error? - Dmitriy Simushev
  • real_escape_string should actually be removed - Ipatiev

1 answer 1

Check return values

mysqli_stmt :: prepare

Return values

Returns TRUE on success, or FALSE on error.

 if (!$add->prepare("INSERT INTO hystsukategories (name,image,text) VALUES (?, ?, ?)")) die($add->error); 
  • Thank you gave an error, showed that the error in the value of the field - dantelol