Contencation Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Contencation Problem

Post by Benjamin »

Why is this returning 0?

Code: Select all

private function addHiddenValue($name, $value)
    {
        $this->hidden .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . $this->lf;
    }

   // from inside another function...
   $x .= '<tr><td colspan="5">' . $this->hidden . $this->lf
        .'<input type="Submit" value="Submit" /></td></tr>' . $this-lf;
        echo "The value of x is $x";
        echo "The value of hidden is $this->hidden";
The value of x is 0
The value of hidden is 0
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Did you notice this?

Code: Select all

$this-lf;
Not that this will make it do what you are getting, but maybe...

Code: Select all

private function addHiddenValue($name, $value)
{
    // Make $this->hidden into a string var
    $this->hidden .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />' . $this->lf;
}

Code: Select all

// from inside another function...
// Make the var $x into a sting with a string inside of it
// This assumed that the call to $this->addHiddenValue has already been called
$x .= '<tr><td colspan="5">' . $this->hidden . $this->lf .'<input type="Submit" value="Submit" /></td></tr>' . $this->lf;
echo "The value of x is $x";
echo "The value of hidden is $this->hidden"; // This will only be set if the above method is called before it, no?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Yarrr that fixed it mate. I hate little typo's like that. I've been having a ton of them the last few days. I need a vacation.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

At this time of night, erm, morning, especially in BigMo, you have got to expect a missing '>' or two. Of course, for me right now, five cups of coffee and 60 Oz of CocaCola after 8:00PM almost makes those things happen.

Glad you figured it out.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Everah wrote:Five cups of coffee and 60 Oz of CocaCola
Whoa. Ease up on the caffine boi!
What is it with programmers and caffine?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Woke up at 8:30AM yesterday morning. I posted that post at about 1:45 AM the following morning knowing I still had about 45 minutes of work to do then had to get home and unwind before go to sleep. I finally went to sleep at 3:15 AM and, as you can see here, I am posting at 8:45 AM ish. Little bit of sleep needs something to drive it, eh?
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

OK Everah. I'm not trying to give you a hard time. I'm just a little concerned really, that kind of stuff isn't good for you. Physcially and mentally. As Jerry Springer says "Look after yourselves and each other" and he's right.
Post Reply