Re: [PHP] why won't my array work?
- From: parasane@xxxxxxxxx ("Daniel Brown")
- Date: Fri, 28 Mar 2008 13:27:16 -0400
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim@xxxxxxxxxx> wrote:
[snip!]
[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
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
.
- References:
- why won't my array work?
- From: Jason Pruim
- why won't my array work?
- Prev by Date: Re: [PHP] PHP code to write excel spread*** with multiple workbooks
- Next by Date: Enabling cURL on my Mac
- Previous by thread: RES: [PHP] why won't my array work?
- Next by thread: Re: [PHP] why won't my array work?
- Index(es):