I'm having a problem making the connection to the Mysqli Database, is giving several errors, follow the errors below:
PHP Warning: mysqli_query() expects parameter 1 to be mysqli, null given in D:\web\localuser\riobonitopiscinas\www\acessorios-para-construcao.php on line 63
PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in D:\web\localuser\riobonitopiscinas\www\acessorios-para-construcao.php on line 66
PHP Warning: mysqli_close() expects parameter 1 to be mysqli, null given in D:\web\localuser\riobonitopiscinas\www\acessorios-para-construcao.php on line 84
And my page code is:
<?php
include ('admin/include/conexao.php');
$result = mysqli_query($con,"SELECT * FROM produto WHERE id_subcategoria=78");
while($row = mysqli_fetch_array($result)) {
?>
<?php include ('includes/box.php'); ?>
<?php
}
mysqli_close($con);
?>
My connection code:
<?php
$parseini = parse_ini_file('admin/ini/config.ini', true);
$dsn = sprintf('mysql:dbname=%s;host=%s',$parseini['bancodedados']['dbname'], $parseini['bancodedados']['host']);
try {
$conexao = new PDO($dsn, $parseini['bancodedados']['usuario'], $parseini['bancodedados']['senha']);
} catch (PDOException $e) {
die('Connection failed: ' . $e->getMessage());
}
?>