Re: no temp var for mysql_fetch_array results

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

 



Jeff, et al --

...and then jeffrey_n_Dyke@xxxxxxxxx said...
% 
[quoting me]
% 
% >mysql_fetch_array() returns an array, and I know I want a field from just
% >this one row (not looping), could I just
% >
% >  $i = mysql_fetch_array($r)[0] ;
% 
% Hi David....
%       How about:
%       $i = mysql_result(mysql_query($q,$dbro),0);

Well, I *thought* it was perfect.  Unfortunately, it ain't in practice.

Running

  $r = mysql_query("select ID from customer where EMail = '$email'",$dbro) ;
  $row = mysql_fetch_array($r) ;
  $id = $row[0] ;

works, but

    $id = mysql_result(mysql_query("select ID from customer where EMail = '$email'",$dbro),0) ; 

or even

  $r = mysql_query("select ID from customer where EMail = '$email'",$dbro) ;
  $id = mysql_result($r,0) ;

fails with

  Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 4...

Now this makes some sense; the manual says that

  mysql_result ( resource result , int row )

will jump to row $row in the output but says nothing about returning me a
given fields.

Any other thoughts?


% HTH
% Jeff


TIA again & HAND
:-D
-- 
David T-G
davidtg@xxxxxxxxxxxxxxx
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00105.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux