pstrg Posted September 11, 2009 Share Posted September 11, 2009 I'm stuck with a parameter passing problem. Situation is as follows: index.htm contains the following: <head> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=main.php?pg=home"> </head> index.php should thus pass 'home' as a value to main.php main.php is a FRAMESET and contains: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <?php /*session_start() ;*/ require('txt.php') ; ?> <FRAMESET ROWS="*,2,500,*" BORDER="0" FRAMEBORDER="no" FRAMESPACING="0"> <FRAME SRC="top.htm" NAME="top" SCROLLING="no" NORESIZE MARGINWIDTH=0 MARGINHEIGHT=0> <FRAME SRC="h.htm" NAME="top" SCROLLING="no" NORESIZE MARGINWIDTH=0 MARGINHEIGHT=0> <FRAMESET COLS="758,2,*" BORDER="0" FRAMEBORDER="no" FRAMESPACING="0"> <FRAME SRC="main-left.php?pg=<?php echo $_get['pg'] ; ?>" NAME="main" SCROLLING="no" NORESIZE MARGINWIDTH=0 MARGINHEIGHT=0> Since 'home' has been passed as the value of pg, the code within the last FRAME statement (above) should be interpreted as SRC="main-left.php?home" NAME="main" In other words, the same value ('home') passed from index.htm to main.php should now be passed to main-left.php. main-left.php by its turn contains: <?php echo $_GET['pg']; ?> However, the word home does not appear on that frame. What am I doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/ Share on other sites More sharing options...
kratsg Posted September 11, 2009 Share Posted September 11, 2009 Try: <?={$_GET['pg']} ?> Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-916798 Share on other sites More sharing options...
Mark Baker Posted September 11, 2009 Share Posted September 11, 2009 or preferably even: <?php echo $_GET['pg']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-916801 Share on other sites More sharing options...
kratsg Posted September 11, 2009 Share Posted September 11, 2009 or preferably even: <?php echo $_GET['pg']; ?> Perhaps even. <?php echo {$_GET['pg']}; ?> Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-916803 Share on other sites More sharing options...
mikesta707 Posted September 11, 2009 Share Posted September 11, 2009 or if you're feeling froggy <?php echo $pg = $_GET['pg']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-916810 Share on other sites More sharing options...
KevinM1 Posted September 11, 2009 Share Posted September 11, 2009 or preferably even: <?php echo $_GET['pg']; ?> Perhaps even. <?php echo {$_GET['pg']}; ?> Actually, Mark has a point. Short tags may not be turned on. It's always best to use the standard and always supported: <?php ?> Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-916947 Share on other sites More sharing options...
pstrg Posted September 12, 2009 Author Share Posted September 12, 2009 @all Thanks pals; however, something remains wrong. (PHP 5.2.10) On target page main-left.php I first set $pg = $_GET['pg']; $image['home'] = "img/image.gif" ; Then, if I use either options below (on line 56) <img src="<?php echo $image[$pg] ; ?>" alt="legend"/> <img src="<?php echo $image[$_GET['pg']] ; ?>" alt="legend"/> I get the page as I intended it to appear but instead of the image I get just legend. If I use braces <img src="<?php echo {$image[$pg]} ; ?>" alt="legend"/> I get the following error message complaining of the opening brace: PHP Parse error: syntax error, unexpected '{' in (...)\main-left.php on line 56 Examining page source for the frame seems to indicate that the value ('home') of parameter pg has not been passed from index.htm to main.php and to main-left.php. Just to recall: index.htm <META HTTP-EQUIV="Refresh" CONTENT="0;URL=main.php?pg=home"> main.php <FRAME SRC="main-left.php?pg=<?php echo $_GET['pg'] ; ?>" NAME="main" SCROLLING="no" NORESIZE MARGINWIDTH=0 MARGINHEIGHT=0> Still wondering... Quote Link to comment https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-917128 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.