print_r affects the data?

OK I think this is the weirdest yet.  To me, anyway.

If I leave in lines 3,4,5 the code appears to work (displays the array, shows no error).

If I comment out those lines, it fails
Severity: Notice

Message: Undefined offset: 0

Filename: models/Week_fixtures_model.php

Line Number: 490

if ( $query->num_rows() == 1)
		{
			echo "<PRE>";
			print_r($query->result_array());
			echo "</PRE>";
			$arr_venue_info['name'] = $query->result_array[0]['name'];
			$arr_venue_info['mapref'] = $query->result_array[0]['mapref'];
			return $arr_venue_info;	
		}
		else // no ground found.
		{
			$arr_venue_info['name'] = $venue;
			$arr_venue_info['mapref'] = 'No map';
			return $arr_venue_info;	
		}

Open in new window


Can anyone shed any light on this please?  I'm using CodeIgniter if that is relevant.
LVL 3
Colin BrazierAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
result_array() Likely actually causes the data to be fetched and without it, you don't have any data.  'printr()' just prints the results.   I don't find any such command in PHP database drivers.  Is that a CodeIgniter command?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Colin BrazierAuthor Commented:
Ah OK, so what I need is
if ( $query->num_rows() == 1)
		{
			$my_array = $query->result_array();
			$arr_venue_info['name'] = $my_array[0]['name'];
			$arr_venue_info['mapref'] = $my_array[0]['mapref'];
			return $arr_venue_info;	
		}
		else // no ground found.
		{
			$arr_venue_info['name'] = $venue;
			$arr_venue_info['mapref'] = 'No map';
			return $arr_venue_info;	
		}

Open in new window

0
Colin BrazierAuthor Commented:
Thanks Dave.  I need a holiday!
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.