Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2005, 09:03 AM
jackti jackti is offline
 
Join Date: Jan 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 01-30-2005, 10:49 AM
Tekton Tekton is offline
 
Join Date: Jun 2004
Location: Wisconsin
Posts: 362
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shouldn't you put that kind of code in the phpinclude start template instead of the header?
Reply With Quote
  #3  
Old 01-30-2005, 11:34 AM
jackti jackti is offline
 
Join Date: Jan 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Tekton
Shouldn't you put that kind of code in the phpinclude start template instead of the header?
Sorry guess I didn't explain it too well, but that's where it's called from yes and not the actual headertemplate within vB.

Still $_GET['do'] or whatever within my header.php (called from phpinclude_start) turn out blank no matter what I try.
Reply With Quote
  #4  
Old 01-30-2005, 11:46 AM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'];
Then use $var wherever you're trying to use that variable.
Code:
if (!isset($var)){

   blah blah blah

} else {

   yadda yadda yadda

}
Reply With Quote
  #5  
Old 01-30-2005, 12:08 PM
jackti jackti is offline
 
Join Date: Jan 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Jolten
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:
Then use $var wherever you're trying to use that variable.
Thanks, but I already tried it, and no luck.

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
print_r($_GET);
// This results in the correct output as i would expect from the URL string I'm using.
I do the same thing, except load "header.php" from the showpost.php in vbulletin (through the phpinclude template), and _nothing_.

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
print_r($_GET);
// This results in the correct output as i would expect from the URL string I'm using.

and add this to the same file:
$brand_new_var = $_GET['whatever'];
echo $brand_new_var;
// Still works great!
Then I add this in my header.php, and call it from a vbulletin page.

Code:
// Inside header.php called from showpost.php
echo $brand_new_var;
// Nothing again!!
I'm really out of ideas, like i said I'm not a PHP guru of any kind, I'm sure there's a perfectly simple reason for this but ahve no clue where to start looking, and for what.
Reply With Quote
  #6  
Old 01-30-2005, 12:21 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 01-30-2005, 12:34 PM
jackti jackti is offline
 
Join Date: Jan 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

adding it to global.php is the same story.

Code:
// Top of global.php, load a vb-page...
$brand_new_var = $_GET;
print_r($brand_new_var);
// Works!
Code:
// Top of header.php called from showpost.php
print_r($brand_new_var);
// Nothing

// then..
print_r($_GET);
// you get a empty array here...
Code:
// Top of header.php called from myownpage.php
print_r($brand_new_var);
// Nothing, of coarse ;)

// then..
print_r($_GET);
// works fine
Reply With Quote
  #8  
Old 01-30-2005, 12:36 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 01-30-2005, 12:55 PM
jackti jackti is offline
 
Join Date: Jan 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

: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.
Reply With Quote
  #10  
Old 01-30-2005, 01:04 PM
Jolten Jolten is offline
 
Join Date: Mar 2004
Posts: 749
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:50 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
  • Page Generation 0.04422 seconds
  • Memory Usage 2,241KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete