CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeCharge.Discussion

 global variable

Print topic Send  topic

Author Message
Eddy - IntraManga
Posted: 05/24/2002, 4:39 AM

Hi ,

Anybody any idea how to place a global variable in the beginning of a
function.

I tried the "open event " but there is comes too late. I want to be able to
use the var BEFORE the $swhere statement , so I can use it in my $swhere
statement.

It works fine if I place it there manually , but doing this after every save
??? Getting tired of this after 150 times :-)

Thanks a lot.

Eddy


Alexey Alexapolsky
Posted: 05/24/2002, 5:46 AM

It's not necessary to put global declarations into the very beginning of
function body.
You can declare variable global in Open event ,
and use it in the next like with $sWhere.

--
Alex
CodeCharge Developer


"Eddy - IntraManga" <ed@lamanga.org> wrote in message
news:acl8ot$cd6$1@news.codecharge.com...
> Hi ,
>
> Anybody any idea how to place a global variable in the beginning of a
> function.
>
> I tried the "open event " but there is comes too late. I want to be able
to
> use the var BEFORE the $swhere statement , so I can use it in my $swhere
> statement.
>
> It works fine if I place it there manually , but doing this after every
save
> ??? Getting tired of this after 150 times :-)
>
> Thanks a lot.
>
> Eddy
>
>
>

Eddy - IntraManga
Posted: 05/24/2002, 6:25 AM

Hi Alex ,
hm , I tried this , but it does not seem to work.
As you can see in the code , I am using the $mytemp var in the $swhere
statement. So it should be declared before . If I use the "Menu Open Event"
it comes after the $swhere and so does not read it. If I place my global var
manually somewhere before the $swhere everything works perfect.
Any other suggestions ?
Thanks,
Eddy,


CODE:
function Menu_show()
{
//-------------------------------
// Initialize variables
//-------------------------------

global $tpl;
global $db;
global $sMenuErr;
$sWhere = "";
$sOrder = "";
$sSQL = "";
$sFormTitle = "";
$HasParam = false;


$tpl->set_var("TransitParams", "");
$tpl->set_var("FormParams", "pagnr=" . tourl(get_param("pagnr")) . "&");

//-------------------------------
// Build WHERE statement
//-------------------------------
$ppagnr = get_param("pagnr");
if(is_number($ppagnr) && strlen($ppagnr))
$ppagnr = tosql($ppagnr, "Number");
else
$ppagnr = "";

if(strlen($ppagnr))
{
$HasParam = true;
$sWhere = $sWhere . "p.page_id=" . $ppagnr;
}


if($HasParam)
$sWhere = " WHERE (show_page=1 and (page_id in
(100,200,300,400,500,600,700,800,900,1000,10000) or (page_id>". ($mytemp -
49) . " and page_id<" . ($mytemp + 49) . ") or page_id=" . ($mytemp + 0) .
")) AND (" . $sWhere . ")";
else
$sWhere = " WHERE show_page=1 and (page_id in
(100,200,300,400,500,600,700,800,900,1000,10000) or (page_id>". ($mytemp -
49) . " and page_id<" . ($mytemp + 49) . ") or page_id=" . ($mytemp + 0) .
")";

//-------------------------------
// Build ORDER BY statement
//-------------------------------
$sOrder = " order by p.page_id Asc";

//-------------------------------
// Build base SQL statement
//-------------------------------
$sSQL = "select p.page_id as p_page_id, " .
"p.page_name as p_page_name, " .
"p.submenu as p_submenu, " .
"p.url as p_url " .
" from pages p ";
//-------------------------------

//-------------------------------
// Menu Open Event begin
global $mytemp;
// Menu Open Event end
//-------------------------------


"Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
news:aclcmt$jvg$2@news.codecharge.com...
> It's not necessary to put global declarations into the very beginning of
> function body.
> You can declare variable global in Open event ,
> and use it in the next like with $sWhere.
>
> --
> Alex
> CodeCharge Developer
>
>
> "Eddy - IntraManga" <ed@lamanga.org> wrote in message
>news:acl8ot$cd6$1@news.codecharge.com...
> > Hi ,
> >
> > Anybody any idea how to place a global variable in the beginning of a
> > function.
> >
> > I tried the "open event " but there is comes too late. I want to be able
> to
> > use the var BEFORE the $swhere statement , so I can use it in my $swhere
> > statement.
> >
> > It works fine if I place it there manually , but doing this after every
> save
> > ??? Getting tired of this after 150 times :-)
> >
> > Thanks a lot.
> >
> > Eddy
> >
> >
> >
>
>

Stefan Hogedal
Posted: 05/24/2002, 8:29 AM

In ASP it works to put the "global" variable in the "page open event".

Hope this works equally well in PHP...

/Stefan

"Eddy - IntraManga" <ed@lamanga.org> wrote in message
news:acl8ot$cd6$1@news.codecharge.com...
> Hi ,
>
> Anybody any idea how to place a global variable in the beginning of a
> function.
>
> I tried the "open event " but there is comes too late. I want to be able
to
> use the var BEFORE the $swhere statement , so I can use it in my $swhere
> statement.
>
> It works fine if I place it there manually , but doing this after every
save
> ??? Getting tired of this after 150 times :-)
>
> Thanks a lot.
>
> Eddy
>
>
>

Eddy - IntraManga
Posted: 05/24/2002, 8:37 AM

Hi Stefan,
No , I am afraid it does not , at least not for me :-(
Ed,



"Stefan Hogedal" <stefan.hogedal@tjohoo.se> wrote in message
news:aclm8j$7a8$1@news.codecharge.com...
> In ASP it works to put the "global" variable in the "page open event".
>
> Hope this works equally well in PHP...
>
> /Stefan
>
> "Eddy - IntraManga" <ed@lamanga.org> wrote in message
>news:acl8ot$cd6$1@news.codecharge.com...
> > Hi ,
> >
> > Anybody any idea how to place a global variable in the beginning of a
> > function.
> >
> > I tried the "open event " but there is comes too late. I want to be able
> to
> > use the var BEFORE the $swhere statement , so I can use it in my $swhere
> > statement.
> >
> > It works fine if I place it there manually , but doing this after every
> save
> > ??? Getting tired of this after 150 times :-)
> >
> > Thanks a lot.
> >
> > Eddy
> >
> >
> >
>
>

Eddy - IntraManga
Posted: 05/26/2002, 12:52 AM

> It's not necessary to put global declarations into the very beginning of
> function body.
Alex , I think you are wrong here. Try this :
<?php
function my_function () {
global $REMOTE_ADDR;
echo $REMOTE_ADDR;
}
my_function ();
?>

WORKS FINE , now this wont work at all :

<?php
function my_function () {
echo $REMOTE_ADDR;
}
global $REMOTE_ADDR;
my_function ();
?>

So , Is there some alternative way somewhere (except doing it manually
everytime) to place global vars in the beginning of the function , BEFORE
the $swhere ?

Thanks again ,
Ed,




"Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
news:aclcmt$jvg$2@news.codecharge.com...
> It's not necessary to put global declarations into the very beginning of
> function body.
> You can declare variable global in Open event ,
> and use it in the next like with $sWhere.
>
> --
> Alex
> CodeCharge Developer
>
>
> "Eddy - IntraManga" <ed@lamanga.org> wrote in message
>news:acl8ot$cd6$1@news.codecharge.com...
> > Hi ,
> >
> > Anybody any idea how to place a global variable in the beginning of a
> > function.
> >
> > I tried the "open event " but there is comes too late. I want to be able
> to
> > use the var BEFORE the $swhere statement , so I can use it in my $swhere
> > statement.
> >
> > It works fine if I place it there manually , but doing this after every
> save
> > ??? Getting tired of this after 150 times :-)
> >
> > Thanks a lot.
> >
> > Eddy
> >
> >
> >
>
>

Alexey Alexapolsky
Posted: 05/27/2002, 4:45 AM

Eddy , try this wrapper trick :

declare this php function , say , in Page/Open event

function get_global_variable() {

global $variable_name;
return $variable_name;

}

and use this function instead of variable in your custom sql.

--
Alex
CodeCharge Developer


"Eddy - IntraManga" <ed@lamanga.org> wrote in message
news:acq48n$qbr$1@news.codecharge.com...
> > It's not necessary to put global declarations into the very beginning of
> > function body.
> Alex , I think you are wrong here. Try this :
> <?php
> function my_function () {
> global $REMOTE_ADDR;
> echo $REMOTE_ADDR;
> }
> my_function ();
> ?>
>
> WORKS FINE , now this wont work at all :
>
> <?php
> function my_function () {
> echo $REMOTE_ADDR;
> }
> global $REMOTE_ADDR;
> my_function ();
> ?>
>
> So , Is there some alternative way somewhere (except doing it manually
> everytime) to place global vars in the beginning of the function , BEFORE
> the $swhere ?
>
> Thanks again ,
> Ed,
>
>
>
>
> "Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
>news:aclcmt$jvg$2@news.codecharge.com...
> > It's not necessary to put global declarations into the very beginning of
> > function body.
> > You can declare variable global in Open event ,
> > and use it in the next like with $sWhere.
> >
> > --
> > Alex
> > CodeCharge Developer
> >
> >
> > "Eddy - IntraManga" <ed@lamanga.org> wrote in message
> >news:acl8ot$cd6$1@news.codecharge.com...
> > > Hi ,
> > >
> > > Anybody any idea how to place a global variable in the beginning of a
> > > function.
> > >
> > > I tried the "open event " but there is comes too late. I want to be
able
> > to
> > > use the var BEFORE the $swhere statement , so I can use it in my
$swhere
> > > statement.
> > >
> > > It works fine if I place it there manually , but doing this after
every
> > save
> > > ??? Getting tired of this after 150 times :-)
> > >
> > > Thanks a lot.
> > >
> > > Eddy
> > >
> > >
> > >
> >
> >
>
>

Eddy - IntraManga
Posted: 05/27/2002, 5:15 AM

Hi Alex, you just made my day !
NICE thinking - workaround !
Works perfect ! Thank you verrryyyyy much.
After a week struggling with this one , such a simple solution , cannot
believe it.
Thanks again,
Eddy,



"Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
news:act67t$5mp$2@news.codecharge.com...
> Eddy , try this wrapper trick :
>
> declare this php function , say , in Page/Open event
>
> function get_global_variable() {
>
> global $variable_name;
> return $variable_name;
>
> }
>
> and use this function instead of variable in your custom sql.
>
> --
> Alex
> CodeCharge Developer
>
>
> "Eddy - IntraManga" <ed@lamanga.org> wrote in message
>news:acq48n$qbr$1@news.codecharge.com...
> > > It's not necessary to put global declarations into the very beginning
of
> > > function body.
> > Alex , I think you are wrong here. Try this :
> > <?php
> > function my_function () {
> > global $REMOTE_ADDR;
> > echo $REMOTE_ADDR;
> > }
> > my_function ();
> > ?>
> >
> > WORKS FINE , now this wont work at all :
> >
> > <?php
> > function my_function () {
> > echo $REMOTE_ADDR;
> > }
> > global $REMOTE_ADDR;
> > my_function ();
> > ?>
> >
> > So , Is there some alternative way somewhere (except doing it manually
> > everytime) to place global vars in the beginning of the function ,
BEFORE
> > the $swhere ?
> >
> > Thanks again ,
> > Ed,
> >
> >
> >
> >
> > "Alexey Alexapolsky" <alexa@codecharge.com> wrote in message
> >news:aclcmt$jvg$2@news.codecharge.com...
> > > It's not necessary to put global declarations into the very beginning
of
> > > function body.
> > > You can declare variable global in Open event ,
> > > and use it in the next like with $sWhere.
> > >
> > > --
> > > Alex
> > > CodeCharge Developer
> > >
> > >
> > > "Eddy - IntraManga" <ed@lamanga.org> wrote in message
> > >news:acl8ot$cd6$1@news.codecharge.com...
> > > > Hi ,
> > > >
> > > > Anybody any idea how to place a global variable in the beginning of
a
> > > > function.
> > > >
> > > > I tried the "open event " but there is comes too late. I want to be
> able
> > > to
> > > > use the var BEFORE the $swhere statement , so I can use it in my
> $swhere
> > > > statement.
> > > >
> > > > It works fine if I place it there manually , but doing this after
> every
> > > save
> > > > ??? Getting tired of this after 150 times :-)
> > > >
> > > > Thanks a lot.
> > > >
> > > > Eddy
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.