To make sure my database is safe, I use preparation instructions. Here is my code:
//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);
Now I want to know how I can use the ASSOC fetch array
$embInfo = mysqli_fetch_array($stmt, MYSQLI_ASSOC);
I want so that I can just add something like below to get the values
$embInfo['name']
and
$embInfo['email']
source share