For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > variable substitution









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author variable substitution
Najm Hashmi

2005-12-07, 9:55 pm

Hi All,
I have the following query:
$query="select CATEGORYID,CATEGORYCODE,ISLEAF from Category C where
C.TOPROOTID = {$TOPROOTID} AND C.PTID=0";

The value for $TOPROOTID does not get substituted. The same query works fine
in windows environment. Further more $TOPROOTID is being passed in URL as
following:
localhost/ViewDocument.php?TOPROOTID=1&ROOTLABEL=NT-proBNP%20and%20CHF&CATEG
ORYID=129

The OS is Red Hat9 and RDBMS is Oracle 9i.

The same code works fine in windows but on Linux I am having problem.
Thanks in advance for your help.

Best regards,
Najm



ZeldorBlat

2005-12-07, 9:55 pm

Probably not so much a Windows/Linux issue as it is a php.ini issue.
What happens if you throw this right before your build $query :

$TOPROOTID = $_GET['TOPROOTID'];

My guess is that it works. Register globals is probably disabled on
your Linux setup. While you should probably write your scripts to work
without register globals, I realize that isn't always practical.

Najm Hashmi

2005-12-08, 6:59 pm

Yes it did work; however, I am facing another issue and will post it later.
Thanks again.
Najm
"ZeldorBlat" <zeldorblat@gmail.com> wrote in message
news:1134009666.346303.256280@g14g2000cwa.googlegroups.com...
> Probably not so much a Windows/Linux issue as it is a php.ini issue.
> What happens if you throw this right before your build $query :
>
> $TOPROOTID = $_GET['TOPROOTID'];
>
> My guess is that it works. Register globals is probably disabled on
> your Linux setup. While you should probably write your scripts to work
> without register globals, I realize that isn't always practical.
>



Jim Michaels

2006-01-16, 9:55 pm

change {$TOPROOTID} to just $TOPROOTID and it will work.
if you want brackets, it should be ${TOPROOTID}

"Najm Hashmi" <najmhashmi@videotron.ca> wrote in message
news:in0mf.5755$FP6.122177@wagner.videotron.net...
> Yes it did work; however, I am facing another issue and will post it
> later.
> Thanks again.
> Najm
> "ZeldorBlat" <zeldorblat@gmail.com> wrote in message
> news:1134009666.346303.256280@g14g2000cwa.googlegroups.com...
>
>



Jim Michaels

2006-01-19, 6:58 pm

I think I was wrong. along those lines, I finally found {$variable} in the
manual by searching for the word "substitution". I wasn't in that habit of
using curly braces.
an excerpt from the CHM manual:
To embed the value of an object member variable into a string you simply
write "text {$obj->member} text" while in PHP 3 you had to use something
like "text ".$obj->member." text".

whatever I say is probably irrelevant anyway - I think the register globals
guy got it.

"Jim Michaels" <jmichae3@yahoo.com> wrote in message
news:_P-dnVYXsPwtklHenZ2dnUVZ_sudnZ2d@comcast.com...
> change {$TOPROOTID} to just $TOPROOTID and it will work.
> if you want brackets, it should be ${TOPROOTID}
>
> "Najm Hashmi" <najmhashmi@videotron.ca> wrote in message
> news:in0mf.5755$FP6.122177@wagner.videotron.net...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com