Jump to content

Recommended Posts

I'm having an unexpected problem with PHP.. I am simply trying to assign a variable!

This line works:
[code]echo $order->delivery['city'];[/code]  output: BRISTOL

This line DOES NOT work:
[code]
$city = $order->delivery['city'];
echo $city;
[/code] output: NOTHING

Any ideas why?

Mike
Link to comment
https://forums.phpfreaks.com/topic/20388-simple-php-problem/
Share on other sites

[quote author=obsidian link=topic=107644.msg432060#msg432060 date=1157982081]
are you doing both of those on the same page? my question is, on the second example, are you instantiating the $order object before you try to access it?
[/quote]

Yes I am..  I can place the statements directly after each other on the same page.

The class is part of the osCommerce package.  So I don't think posting the class would be wise, as it would involve posting a few thousand lines of code of a couple of different classes..

or maybe I should? hmm..  I'm not *that* confident with PHP, but i expected that to work! ???
Link to comment
https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89789
Share on other sites

var_dump returns nothing as well..  Maybe if i put it in context that will help:

[code]
// class methods
    function quote($method = '') {
      global $order;

      //GET THE CITY HERE
      $city = $order->delivery['city'];

      $this->quotes = array('id' => $this->code,
                            'module' => MODULE_SHIPPING_FLAT_TEXT_TITLE,
                            'methods' => array(array('id' => $this->code,
                                                    'title' => $city,
                                                    'cost' => MODULE_SHIPPING_FLAT_COST)));

      if ($this->tax_class > 0) {
        $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
      }

      if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

      return $this->quotes;
    }
[/code]

In the above case, 'title' is blank when returned. However if i subsitute this line:

[code]'title' => $city,[/code]

For this:

[code]$order->delivery['city'][/code]

It works.

??
Link to comment
https://forums.phpfreaks.com/topic/20388-simple-php-problem/#findComment-89805
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.