Avatar billede jadirir Nybegynder
06. oktober 2002 - 21:57 Der er 10 kommentarer

Parameter passing

Hej All.
I want to call a function with a parameter on a same page, but it does not shows. The link to call it I wrote as: ---<a href="'.$PHP_SELF.'?event=callparam&num='.$id.'">link</a>---.
Please let me know should I call.
THANKS.
Avatar billede nicklasb Nybegynder
06. oktober 2002 - 22:01 #1
you have to put et in a <? ?>
like:

<? echo "<a href=\"'.$PHP_SELF.'?event=callparam&num='.$id.'\">link</a>"; ?>

/Nicklas B.
Avatar billede nicklasb Nybegynder
06. oktober 2002 - 22:03 #2
no.. use this..
<? echo "<a href=\"$PHP_SELF?event=callparam&num=$id\">link</a>"; ?>
Avatar billede jadirir Nybegynder
06. oktober 2002 - 22:06 #3
Not yet. I put already as the code is php code.
thanks
Avatar billede nicklasb Nybegynder
06. oktober 2002 - 22:08 #4
try witout the '. and the .'
www.bornstein.dk/tes.php
here it works..
Do you remember to save as index.PHP ??
Avatar billede nicklasb Nybegynder
06. oktober 2002 - 22:11 #5
here is the code of what you se at www.bornstein.dk/tes.php ;

<?
$id = 1;
echo "<a href=\"$PHP_SELF?event=callparam&num=$id\">link</a>";
?>
Avatar billede jadirir Nybegynder
06. oktober 2002 - 22:13 #6
It shows the link on the URL field as well as status bar, but it could not call the function "callparam" with parameter "num"
Avatar billede nicklasb Nybegynder
06. oktober 2002 - 22:17 #7
a litle error in my code.. Try see it now..
Now it links to http://www.bornstein.dk/tes.php?event=callparam&num=1
Avatar billede jadirir Nybegynder
06. oktober 2002 - 22:28 #8
Following code is in one php file:
//this is the call link
<a href="'.$PHP_SELF.'?event=fullStory&id='.$id.'">LINK</a>
//This is the function to call
function fullStory(){
    global $id;
//function body
}
//this is the switch
switch($event){
    case("fullStory"):
      fullStory();
      break;
....
....
}
The link never calls the fullStory function even it shows on the URL field.
Avatar billede barlach Nybegynder
07. oktober 2002 - 23:22 #9
try
switch($_GET['event']){

or try to echo $event and $id to see if they exist...
Avatar billede jadirir Nybegynder
08. oktober 2002 - 08:05 #10
THank you all I got it. The problem was configuration of the php.ini file. There is line to set on to recognise the globel variables.
THANKS.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB

Netcompany A/S

Network Engineer

Supporters A/S

Support specialist

Forsvarsministeriets Materiel- og Indkøbsstyrelse

DevOps Engineer (AI) til Forsvarets nye IT-platform

KMD A/S

Project Manager

HusCompagniet A/S

Senior data engineer