0

(PHP newb here--can read code somewhat well, working on writing)

I think I have an array in an array. using this for MySQL calls:

https://github.com/ajillion/PHP-MySQLi-Database-Class

my call:

$params = array($mta_name);
$mta_uid = $db->rawQuery("SELECT mta_uid FROM mtas WHERE mta_name = ?", $params);
echo print_r($mta_uid);

ends up with this:

Array ( [0] => Array ( [mta_uid] => 1 ) ) 1

I just want the '1' . Have tried mta_name['0'] and ['1'] and ['0']['1'] / ['1']['0'] / ['1']['2'] etc.

Whenever I have issues always find you guys and usually solves. First time posting.

Many thanks!

Ynhockey
  • 3,845
  • 5
  • 33
  • 51
brizz
  • 271
  • 1
  • 6
  • 17
  • Where did `uid` come from? Either your query has `SELECT uid` or the result should have `[mta_uid]`. – Barmar Sep 19 '13 at 03:02
  • sorry for confusion. edited and posted on personal forums--and then copied from there. always was supposed to be mta_uid. was just trying to simplify for personal forums. – brizz Sep 19 '13 at 03:36
  • ajilion MySQLidb Class is absolutely unusable. – Your Common Sense Sep 19 '13 at 05:42

1 Answers1

2

This should work

echo $mta_name[0]['uid'];

The inner array has named elements, not simple number indexed.

Barmar
  • 741,623
  • 53
  • 500
  • 612
Fluffeh
  • 33,228
  • 16
  • 67
  • 80