I am having a little problem passing from mysql_* to mysqli object oriented.
My index.php file is structured like including two files:
include('connect.php');
include('function.php');
The connect.php file contains:
<?php
$mysqli = new mysqli("localhost", "root", "test", "test");
if (mysqli_connect_errno($mysqli)) {
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
}
?>
In the function.php file there is a function called showPage that takes no arguments but uses the $mysqli connection, in lines like...
$result = $mysqli -> query("SELECT * FROM $table ORDER BY ID DESC"); // Seleziono tutto il contenuto della tabella
I cannot manage it to work without passing to the function the $mysqli variable, but this was not necessary when I used mysql_* deprecated functions!
Can I understand why, and what's the best way to resolve this?