![]() |
Variables turning blank.
Hope you guys can help me out a bit on this.
What I'm doing is this: In my vbulletin $header, I have my own template + some code to set cookies and stuff that has nothing to do with vbulletin, this is supposed to happen on both vbulletin pages and non-vbulletin pages.. What happens is, if i call my header.php from my own pages, it works great.. but when the header.php file gets called from a vbulletin page, i can not work with variables, they are blanked some where along the way (like $_GET['whatever'] and such will not work). Specifically, i want $_GET['do'], and $_POST['vb_login_username/password'] to get passed along, but they refuse to, even if i try reassigning them to different variables inside vb itself, they also get blanked by the time they get to my includes. I'm not that seasoned with PHP, so it's like looking for something i don't even know what looks like within the vb code. Help is much welcome |
Shouldn't you put that kind of code in the phpinclude start template instead of the header?
|
Quote:
Still $_GET['do'] or whatever within my header.php (called from phpinclude_start) turn out blank no matter what I try. |
It's really hard to say without seeing more code.
The best I can offer is to assign the server variables to another variable a la: Code:
$var = $_GET['whatever']; Code:
if (!isset($var)){ |
Quote:
Here's how I tested it and set it up: The file header.php is called from phpinclude_start, header.php includes some setcookie and session management code. On my own pages, where header.php is included.. let's call it my_non_vb_related_page.php, i do this in the include file: Code:
// header.php called from my_non_vb_related_page.php Then I put this in the functions.php file that comes with vbulletin (just to make sure I'm not crazy): Code:
// Inside functions.php Code:
// Inside header.php called from showpost.php |
Try adding it to forum/global.php
And you'll need to include global.php before the variable is called in header.php. That's the root of your problem. You're calling a variable before it's set. Since I assume header.php loads before the vb page scripts. |
adding it to global.php is the same story.
Code:
// Top of global.php, load a vb-page... Code:
// Top of header.php called from showpost.php Code:
// Top of header.php called from myownpage.php |
I edited my post up there :)
---> You'll need to include global.php before the variable is called in header.php. That's the root of your problem. You're calling a variable before it's set. Since I assume header.php loads before the vb page scripts. |
:nervous: lol, you're absolutely right about the case in the middle. I'm not really sure what is called in what order, but I'm thinking that vb must blank some variables before it starts phpinclude because otherwise $_GET would not be blank , right?...
even if it explains why $brand_new_var turns out blank, it doesn't explain why I also get an empty $_GET/$_REQUEST Array in my header ? Thats really the problem, making it into another variable name would just be a way to get around it (if it actually would have worked).. ..also when I try including global.php from my header.php and try loading a page I get a bunch of database errors and the page does not load at all, but I shouldn't need to do that anyway on pages that have nothing to do with vb. |
So... header.php doesn't reside in the same directory as the forums?
You're right though $_GET should still work as long as the variable is present in the url |
your problem is not in code or in templates
the problem is - you using echo / print/print_r this make page blank..... instead of print put the var you want to print in template and it will work. |
No, my header.php is on a whole different domain (same box, just different users)
i tried using chdir() before and after including global.php but it still won't work, something about too many SQL connections after a short time.. (it's looping or something probably). I just have no clue what to do about the whole $_GET-problem and I'm running out of ideas, I appreciate the help a lot though, Thanks. I guess I'll end up print_r'ing $_GET through ~5000 lines of php code to find out where it gets lost =) Nothing like a nice relaxing Sunday afternoon.. It works on the top of global.php, but not at the bottom. I guess thats a start. edit: MIZ, I didn't quite understand what you meant by your post, could you explain it a little more in detail? |
if you try to echo and you use templates
that its wont show anything not the echo and not the templates if you included global this will happen to you but if you will try to do something like PHP Code:
you dont belive me ? try it. also 1 more thing Quote:
PHP Code:
|
Thanks Miz, but the problem isn't that it doesn't have a value, because it does at the top of global.php even when you do it my way as you quoted above. It's supposed to be a variable from the URL string, not a constant from within the script, and by the bottom of global.php the value is gone no matter how you set it..
And I don't want to just print it out in a template inside vb somewhere, I need it for db queries and to set cookies and stuff within my own header.php, and it's blank by the time it gets there. |
you cant print anything when you using global.php
no metter what you will do so right you placed it in top of global.php , after the file runned its shout its down cuse this is the way global works no metter what you will try to do unless you will use the die(); function which stop the file runing. if you need to get all info use global and instead of echo use template functions and put all vars in template this is the best solution you can get |
MIZ, I'm really having problems understanding how to "use the template functions to put the variables in a template"? how exactly would I do that to be able to pass the arrays $_GET, $_POST etc. to my header.php?
And the die(); thing in global makes the forum.. well.. die, and the point is for people to be able to browse the forum :) |
PHP Code:
offcurse in template 'mytemplate' place $myvar inside the template |
All times are GMT. The time now is 02:57 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|