Hi!
I have problem with global variables.
I have 3 files.:
1. db_connection where I define variable $mdb2. I'm holding in $mdb2 the database connection.
2. class file, where define the classes and their functions.
in the beginning of file i'm making "require" to the first file.
and using in declaration like this
3. main fail. there are the communication with template and calling out the classes what i'm usin in 2nd file.PHP Code:class class_name {
function blah() {
globab $mdb2;
.... activity (db queries, calculations etc) ....
}
}
The problem is, if i'm usin the second file directly then everything is working well. but if i'm using 3rd as it should be prober, then it is givin the error that cant make database query.
i log in different places and found out that $mdb2 in function dont get the value. but it has values before calling that class in 3rd file and also when the second file is creating that class.
I don't understand where the problems lies. because all files are "required". and should work.
if i was including the first file into the function after global mdb2 then the sql queries did not fail.
sorry my bad englsih, hope you understand and i'm waiting any help





Bookmarks