I'm facing a strange accidental assignment error on the line if ($row = $result->fetch_array(MYSQLI_ASSOC)){
The code's output is always FALSE so I'm unable to query my database. I'm not sure why it is happening. How can I fix it?
Thanks in advance :)
$con = mysqli_connect("localhost:3306", "apple", "apple", "apple");
if (!$con) {
die("cannot connect: " . mysqli_error());
}
else {
if (isset($_GET['id'])){
$id = $_GET['id'];
$btnNum = $_GET['btnNum'];
mysqli_select_db($con, "apple");
$query = "SELECT * FROM resume where resume_id ='" . $id . "' AND button_match ='" . $btnNum . "'";
$result = mysqli_query($con, $query) or die('Error, query failed');
if ($row = $result->fetch_array(MYSQLI_ASSOC)){
$name = $row['resume_title'];
$type = $row['file_type'];
$content = $row['resume_data']; //content of file
$size = $row['file_size']; //file size
header('Content-Type:"' . $type . '"');
header('Content-Disposition: attachment; filename="' . $name . '"');
echo $content;
}
}
}