Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/173918-_get-doubt/
Share on other sites

@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...

 

Link to comment
https://forums.phpfreaks.com/topic/173918-_get-doubt/#findComment-917128
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.