I have just started a new PHP project and I was thinking it's time to follow php suggestion and stop using mysql and swith to mysqli instead. But this gave me a problem.
Normaly my setup is like this
Index.php file and inside this file I have a 2 require statements. One that calls for the db.php file and one other to call a functions.php file. So far so good.
In the functions.php file a have a lot of different functions that is used all over the homepage and many of these are using SQL. With php old mysql API this was no problem but it seams that the new mysqli api don't allow connections to be used from included files???
For example in my db.php I have the connect statement. $db = mysql_connect(*******);
And in my function.php I have mysql_query(******)
and it works perfect.
But if I change the db.php to $db = mysqli_connect(*****);
Then in my function.php file I can't call the mysqli_query(***)
. (I have also tested object oriented but it gives me the same problem).
So how to get around this problem? Is php expecting me to put the mysqli_connect statement in the beginning of every file that uses sql statements?