Re: why won't my array work?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim@xxxxxxxxxx> wrote:
[snip!]
>
>  $oldpasswordquery = "SELECT loginPassword, Record FROM current WHERE
>  loginPassword='{$oldPassHash}' AND Record='{$Record}'";
>  $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or
>  die("Sorry read failed: ". mysqli_error($chpwpostlink));
>  $chpwresult = $chpwold[0];
>  $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t
>  work....' .mysqli_error($chpwpostlink));
>  echo $chpwrow['loginPassword'];
>  print_r($chpwrow);
>
>
>  The echo and the print_r are for debugging and obviously wont' be in
>  the final script... Here is the error that I am getting:
>
>  [Fri Mar 28 12:14:39 2008] [error] PHP Notice:  Undefined index:
>  loginPassword in /Volumes/RAIDer/webserver/Documents/dev/OLDBv2/admin/
>  chpwpost.php on line 18
[snip!]

    Let's explain this a bit....

        $chpwrow[] = mysqli_fetch_assoc($chpwresult) // ....

    The response from mysqli_fetch_assoc() will be an array already.
You're then adding this into the $chpwrow[] array, which creates a
nested array.  So to call it from your example, you'd need
$chpwrow[0]['loginPassword'].



-- 
</Daniel P. Brown>
Forensic Services, Senior Unix Engineer
1+ (570-) 362-0283

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux