为了确保我的数据库是安全的,我使用了准备语句。这是我的代码:
//connecting to MySql database
$con=mysqli_connect("host","user","pass","dbname");
// checking database connection
if (mysqli_connect_errno($con)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$stmt = mysqli_prepare($con,"SELECT * FROM `table` WHERE emb=? LIMIT 1");
mysqli_stmt_bind_param($stmt, 's', $emb);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
现在我想知道如何使用 ASSOC 获取数组
$embInfo = mysqli_fetch_array($stmt, MYSQLI_ASSOC);
我想要这个,这样我就可以在下面放一些东西来获取值
$embInfo['name']
和
$embInfo['email']