Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

passing variables to an include file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

passing variables to an include file

Postby sametch » Mon May 05, 2003 4:22 am

I have a page, which receives a variable $pageid from another page using the get method. The receiving page needs to use the value of $pageid in an include file which it calls.

I dont seam to be able to get it to work. I can display the value of $pageid at the top of the actual page no problem. But if I use the variable $pageid in the code of the included file it ends up with no value.

Am I doing something wrong.

example:

main page code:

<?
echo "pageid = ".$pageid"; //this displays the value fine
include include.php;
?>

include file code:

<?
echo "pageid = ".$pageid"; //this doesn't display on the page calling the include it comes up "pageid ="
?>

:(
sametch
New php-forum User
New php-forum User
 
Posts: 17
Joined: Wed Jul 03, 2002 3:10 am

Postby Redcircle » Tue May 20, 2003 1:08 am

$_GET['pageid'] is the correct method. You have register_globals on so you must user the superglobal instead. (which is the correct way to do it)
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.