Re: [PHP] why won't my array work?



On Fri, Mar 28, 2008 at 12:28 PM, Jason Pruim <japruim@xxxxxxxxxx> 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?
.



Relevant Pages

  • Re: Reentrant problem with inet_ntoa in the kernel
    ... 2006/11/3, Brooks Davis: ... >>> to store the result. ... And it returns the address of the array to the ... >>> calling it. ...
    (freebsd-net)
  • Re: Base Normal Form
    ... > What's the difference between calling a table a list of tuples, ... In some formal contexts, I think a list is either empty, or consisting ... In contrast, an array is ... > I'm hazy on the distinction between a relation and a relvar. ...
    (comp.databases.theory)
  • Re: Are these the same arguments?
    ... calling program which were not shown are consistent). ... of the array slices that are changed within the subprogram cannot be ... detail in the the actual calling sequence. ... this is legal in f77 (as long as the actual array elements that are ...
    (comp.lang.fortran)
  • Re: Are these the same arguments?
    ... I think this is correct (assuming that the declarations in the calling program which were not shown are consistent). ... The elements of the array slices that are changed within the subprogram cannot be accessed through two different dummy arguments, and it is up to the programmer to ensure that this does not happen. ... After seeing a couple other responses, I realize that I overlooked a detail in the the actual calling sequence. ... I remember a discussion from several years ago about f77, and I'm pretty sure that this is legal in f77. ...
    (comp.lang.fortran)
  • Embedding Python in C
    ... but modifiying it now as a function inside my C/C++ code. ... Problem started when I started passing an array as an argument. ... The code for argument building and calling are as follows: ... lies in the list building process. ...
    (comp.lang.python)