sql准备语句没有显示输出

时间:2017-12-17 14:46:30

标签: php mysql prepared-statement

我是准备好的陈述的新手。此功能未显示任何输出。有什么问题?

function  selectFwhere($id) {
    $con = mysqli_connect('localhost','root','','car_rental');
    $sql = mysqli_prepare($con,'SELECT * FROM `car_admin` WHERE admin_id = ?') or die("Unable to prepare statement: " . $con->error);
    $sql->bind_param('i',$id);
    $sql->execute();
    $result = $sql->get_result();
    while($row = $result->fetch_assoc() ){ echo " ".$row['admin_username']; }
    $sql->close();
    $con->close();

    selectFwhere(1);

}

1 个答案:

答案 0 :(得分:0)

在结束selectFwhere(1);

之后,您需要将行}移到函数体外部