PHP7預編譯mysqli查詢操做

   //鏈接數據庫
   $mysqli = new mysqli("localhost", "root", "root", "mobilemoms");
    !$mysqli->connect_error or die("CONNECT SQL ERROR".$mysqli->connect_error);
    $mysqli->query("set names utf8");
    
   //sql預編譯
   $sql = "select tally_name,machine_no from device_member where mobile_no=? and mobile_pwd=? limit 1";
    $mysqli_stmt = $mysqli->prepare($sql);
    
    //綁定參數
    $mysqli_stmt->bind_param("ss",$mobileno,$pwd);//綁定查詢參數
    $mysqli_stmt->bind_result($tally_name,$machine_no);//綁定結果參數 也就是將查詢結果直接給某參數

    //處理查詢結果
    $mysqli_stmt->execute();
    if(!$mysqli_stmt->fetch()){ //沒有內容
        wrong("No User");
    }else{//有內容
        echo "success";
    }  
相關文章
相關標籤/搜索