First let's dissect your code, to which day the part of the error, because syntactic analysis in computing is for the debugger. We'll follow in stages, okay?
Let's talk about each type of php file:
Re-evaluate the use of these functions and try adding the connection script directly to the page that searches the database
require - > require
The require statement is identical to include except that on failure it will also produce a fatal error of level E_COMPILE_ERROR. In other words, it will stop the script while the include will only issue an alert (E_WARNING) allowing the script to continue.
include - > include
The include statement includes and evaluates the reported file.
The following documentation also applies to the require statement.
Files are included based on the path of the given file or, if not entered, the specified include_path. If the file is not found in the include_path, the include statement will check the directory of the script that executes it and the working directory before it fails. The include constructor will issue a warning if it does not locate the file; behaves differently from the require constructor, which will issue a fatal error.
If a path is defined - either absolute (starting with drive letter or \ on Windows, or / on Unix / Linux), or relative to the current directory (starting with .or ..) - the include_path will be completely ignored . For example, if the file name starts with ../, the interpreter will look for the file in the parent directory.
Already another problem that does not really exist, these letters are what you want.
It will not open the image, the script is opening the uncompressed jpg file and throwing the text file into the screen:
'$arquivo = 'imagem.jpg';
header('Content-type: octet/stream');
header('Content-disposition: attachment; filename="'.$arquivo.'";');
readfile($arquivo);'
If you want to open an image you should do so:
<?php
// supondo que $caminho seja o nome da variável
echo '<img src="' . $caminho . '" />';
?>
See if that's what you need and vote for it if my suggestion is reasonable to solve your problem!