0
Hello,
I was using select that way and working perfectly
$id = (int)$_GET["id"];
$banco = $mysqli->query("SELECT os.os_solicitado,os.os_status,cliente.cliente_emailfinanceiro FROM os left join cliente on os.os_razaosocial = cliente.cliente_razaosocial where os.os_id = $id");
while($dados = $banco->fetch_array()) {
$status = $dados["os_status"];
$solicitado = $dados["os_solicitado"];
$emailfin = $dados["cliente_emailfinanceiro"];
But to improve security I’m changing to that way
$stmt = $mysqli->prepare("SELECT os.os_solicitado,os.os_status,cliente.cliente_emailfinanceiro FROM os left join cliente ON os.os_razaosocial=cliente.cliente_razaosocial WHERE os.os_id = ? ");
$stmt->bind_param("s", $_GET['id']);
$stmt->execute();
$stmt->close();
while($dados = $stmt->fetch_array()) {
$status = $dados["os_status"];
$solicitado = $dados["os_solicitado"];
$emailfin = $dados["cliente_emailfinanceiro"];
but this second way gives error, does not connect in the bank and can not identify what is
Post the error that is appearing
– Leonardo Barros
In my case appears Error Connecting to database
– Murilo Albeest
Then put the connection code where you pass the database data, remember to change the actual data to fictitious data.
– Leonardo Barros
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
set_exception_handler(function($e) {
 error_log($e->getMessage());
 exit('Error connecting to database'); //Should be a message a typical user could understand
});
$mysqli = new mysqli("localhost", "root", "", "test"); $mysqli->set_charset("ISO-8859-1");
– Murilo Albeest
remembering that to do without preparing it, works just right
– Murilo Albeest
To facilitate reading, seeks to put additional information in the question itself, editing it.
– Leonardo Barros
replace the content of Exit with
$e->getMessage()
, to see which error is actually happening.– Leonardo Barros
Call to Undefined method mysqli_stmt::fetch_array()
– Murilo Albeest
Let’s go continue this discussion in chat.
– Leonardo Barros