PHP / MySQL help.

Status
Not open for further replies.

lambada

New Member
Messages
2,444
Reaction score
0
Points
0
Right, I have a bug in that when I use mysqli_query() with the correct variables, it says

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/lambada/public_html/v2/includes/blog/countcomments.php on line
9

and

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /home/lambada/public_html/v2/includes/blog/showcomments.php on line 9


The $db is included via several things.

$db is defined in /includes/db/openconnection.php - this file is then included by /index.php at the beginning.

index.php then includes includes/page.php which determines the page to be included. I have coded a small script to work out if it's a file-based module, or a db page. This then includes includes/blog.php . inlcudes/blog.php then includes includes/blog/listall.php ($db still works correectly at this point). Then includes/blog/listall.php then includes includes/blog/countcomments.php and includes/blog/showcomments.php ($db doesn't work in these two files.

Any ideas?

I've attached a zip file of the site so you can see for yourself what I actually mean along with the rather long various code.


EDIT:

I've found the bug. I was using functions without globalling the variables from outside. Sometimes a good nights sleep can work wonders :D

:lockd:
 
Last edited:
Status
Not open for further replies.
Top