savagenoob Posted July 21, 2010 Share Posted July 21, 2010 No freakin clue why this wont echo what I want it to. print_r on the array works but echo'ing individual sections wont work. $query = mysql_query("SELECT * FROM auto WHERE PolNum = '$PolNum' AND Agency = '$agency' ORDER BY ID DESC LIMIT 1") or die(mysql_error()); $clientinfo[] = mysql_fetch_array($query); print_r($clientinfo); echo $clientinfo['Company']; echo $clientinfo[7]; $company = $clientinfo['Company']; echo $company; None of the 3 echos will work.... I know its something simple and/or stupid. Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/ Share on other sites More sharing options...
Pikachu2000 Posted July 22, 2010 Share Posted July 22, 2010 Copy the output from the print_r() here. Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/#findComment-1089363 Share on other sites More sharing options...
savagenoob Posted July 22, 2010 Author Share Posted July 22, 2010 Array ( [0] => Array ( [0] => 47 [iD] => 47 [1] => 679798798 [PolNum] => 679798798 [2] => 2010-05-26 21:12:06 [EffDate] => 2010-05-26 21:12:06 [3] => [PhysStreet] => [4] => Sacramento [PhysCity] => Sacramento [5] => [PhysState] => [6] => 91111 [PhysZip] => 95842 [7] => pOOP Insurance [Company] => pOOP Insurance [8] => 93 [ClientID] => 93 .... Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/#findComment-1089365 Share on other sites More sharing options...
PFMaBiSmAd Posted July 22, 2010 Share Posted July 22, 2010 If you echo <pre></pre> tags around the print_r() it will be clearer what you actually have (you have an array of arrays) - echo "<pre>",print_r($clientinfo,true),"</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/#findComment-1089366 Share on other sites More sharing options...
BillyBoB Posted July 22, 2010 Share Posted July 22, 2010 Just change the output from the db to just a variable not an array $query = mysql_query("SELECT * FROM auto WHERE PolNum = '$PolNum' AND Agency = '$agency' ORDER BY ID DESC LIMIT 1") or die(mysql_error()); $clientinfo = mysql_fetch_array($query); print_r($clientinfo); echo $clientinfo['Company']; echo $clientinfo[7]; $company = $clientinfo['Company']; echo $company; Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/#findComment-1089369 Share on other sites More sharing options...
savagenoob Posted July 22, 2010 Author Share Posted July 22, 2010 jesus i knew it was dumb. thanks guys... removing the [] worked. Quote Link to comment https://forums.phpfreaks.com/topic/208484-simple-array-problem-i-cant-figure-out/#findComment-1089371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.