Re: why won't my array work?

From: Date: Fri, 28 Mar 2008 16:40:01 +0000
Subject: Re: why won't my array work?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-272242@lists.php.net to get a copy of this message
On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim@raoset.com> wrote: > $chpwold[] = mysqli_query($chpwpostlink, $oldpasswordquery) or > die("Sorry read failed: ". mysqli_error($chpwpostlink)); > $chpwresult = $chpwold[0]; Why would you pump that into an array instead of just calling it result itself? I'd say you're just making it harder on yourself for no apparent reason. The problem seems to be on your other line. $chpwrow[] = mysqli_fetch_assoc($chpwresult) or die('Sorry it didn\'t work....' .mysqli_error($chpwpostlink)); echo $chpwrow['loginPassword']; Just fetch the row into a single variable and not an array. In your example you'd need to access chpwrow[0]['loginPassword'] assuming it was an empty array up to that point. Calling things old query and old password isn't really adding any value to your code. If you're only going to use it once then throw it away call it result so it is easier to read and understand. But then again feel free to ignore this. Also is there a reason why you aren't using prepared statements?

« previous php.general (#272242) next »