看了一下英文的
mysqli_stmt_init,初如化一个状态或对象 ,相当于打开了一个资源然后才能调用prepair语句
然后再能使用stmt函数
Example #2 Procedural style
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}$city = "Amersfoort";/* create a prepared statement */
$stmt = mysqli_stmt_init($link);
if (mysqli_stmt_prepare($stmt, 'SELECT District FROM City WHERE Name=?')) {    /* bind parameters for ers */
    mysqli_stmt_bind_param($stmt, "s", $city);    /* execute query */
    mysqli_stmt_execute($stmt);    /* bind result variables */
    mysqli_stmt_bind_result($stmt, $district);    /* fetch value */
    mysqli_stmt_fetch($stmt);    printf("%s is in district %s\n", $city, $district);    /* close statement */
    mysqli_stmt_close($stmt);
}/* close connection */
mysqli_close($link);
?>The above example will output:Amersfoort is in district Utrecht
  

解决方案 »

  1.   

    mysqli::stmt_init -- mysqli_stmt_init — Initializes a statement and returns an object for use with mysqli_stmt_prepare
    初始化一个状态并返回一个对象供mysqli_stmt_prepare使用Description
    Object oriented style (property):mysqli
    mysqli_stmt stmt_init ( void )
    Procedural style :mysqli_stmt mysqli_stmt_init ( mysqli $link )
    Allocates and initializes a statement object suitable for mysqli_stmt_prepare(). 
    Note: Any subsequent calls to any mysqli_stmt function will fail until mysqli_stmt_prepare() was called. 
    在mysqli_stmt_prepare() 调用前,任何mysqli_stmt 函数子调用都将失败(意思是说要想作用mysqli_stmt ,必调用mysqli_stmt_prepare(),而调用mysqli_stmt_prepare(),需要先初始化并返回一个对象)
    Parameterslink 
    Procedural style only: A link identifier returned by mysqli_connect() or mysqli_init() 
    Return Values
    Returns an object.