Solved

PHP - Values not pulling out of array

Posted on 2009-04-02
5
193 Views
Last Modified: 2012-05-06
Please see code below.  $var['address'], etc does not work, can't figure out why.

Thank you!
function officeLocation($country) {
				
				$var = array();
				$var = $this->dealer_array;
				
					if ($country == 'NL' || $country == 'DE') {
						$location = ''.$this->dealer_name.'<br/>Leyenseweg 111c<br/>3721 BC Bilthoven<br/>The Netherlands<br/>
						Phone +31(0) 30 229 30 04<br/>Fax   +31(0) 30 274 00 74';
					} else {
						$location = '	'.$this->dealer_name.'<br/>
										'.$var['address'].'<br/>
										'.$var['phone'].'<br/>
										'.$var['fax'].'<br/>';
					}
					
				return $location;
			}

Open in new window

0
Comment
Question by:vrmetro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24053456
What is the content of $this->dealer_array ?

Show a larger portion of your script.
0
 

Author Comment

by:vrmetro
ID: 24053727
Code outlines below the process.

I returned just the $var array and it's value is 1.  I return $this->dealer_array(invoice class) from the officeLoation function and the value is 1.  

Now you think the dealer_array is simply not set prior to calling in officeLocation(), not true, I did
print_r($invoice->dealer_array);
before calling $location = $invoice->officeLocation($country); and the array output below is what I receive.

Array ( [num] => 101 [name] => Omega GPS [address] => [phone] => [fax] => [countries] => US,BR,MX [vatnum] => [bcolor] => f6f2eb [acolor] => ebe1d1 [hcolor] => f6f2eb [rr1] => ebe1d1 [rr2] => fff [rr3] => e2e0e0 [rr_title_color] => a82f2b [image] => [s_image] => [instid] => 144954 )

Thanks for your help!!!
//Loading common class running this in the constructor:
$this->dealer_array = $this->setDealer();
 
// function setDealer : sets invoice object variables 
	function setDealer() {
		global $database;
		global $invoice;
		
		$data=array();
		$data = $database->select('SELECT * FROM `jos_fw_dealers` WHERE jos_fw_dealers.num=\''.$_REQUEST['m_dealer'].'\'');
		// set in common
		$this->dealer_name = $data['name'];
		$this->dealer_array = $data;
		// set in invoice instance
		$invoice->dealer_array = $data;
		$invoice->dealer_name = $data['name'];
		
		return $data;
	}
 
// all above is ran at initialization
// next we call from the controller
$location = $invoice->officeLocation($country);
// office location function in original post

Open in new window

0
 

Author Comment

by:vrmetro
ID: 24053875
i'm an idiot!  Was grabbing a deal that had no address/phone/etc.

Sorry.
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24053881
>> Array ( [num] => 101 [name] => Omega GPS [address] => [phone] => [fax] => [countries] => US,BR,MX [vatnum] => [bcolor] => f6f2eb [acolor] => ebe1d1 [hcolor] => f6f2eb [rr1] => ebe1d1 [rr2] => fff [rr3] => e2e0e0 [rr_title_color] => a82f2b [image] => [s_image] => [instid] => 144954 )

address, phone and fax are all blank here...?
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24053889
:)
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Checking https returns 301 21 63
Generate PDF from MySQL using PHP 3 56
Session time out quickly. 6 28
How to remove  "0":  in a json string 4 19
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question