I have a small website that I wanted to switch over to the mysqli_* functions, and after reading up a lot on it I decided to do the switch by doing a replace-all mysql_ with mysqli_ — I then went through and verified that everything changed correctly…
Now, the mysqli_connect() works – (I get a valid resource connection back from it) but further down the PHP script I have a mysqli_query function that is returning NULL no matter what I put in as the SQL.
Any thoughts what could be happening?
The relevant code:
function connecti_database() {
mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_DATABASE);
}
connecti_database();
$sql = 'SELECT * FROM table where id = 5';
$result = mysqli_query($sql);
var_dump($result); // this returns NULL every time
mysqli functions require two parameters, not one
…and a developer required to read documentation first.
PHP Manual: http://php.net/manual/en/mysqli.query.php