NYCPHP Meetup

NYPHP.org

[nycphp-talk] can't get one field out of mysql

Oktay Altunergil nyphp at altunergil.com
Fri Aug 30 14:48:00 EDT 2002


you're missing the $ in note[i] up above

oktay

On Fri, 30 Aug 2002 14:42:09 -0400
Michael Southwell <southwell at dneba.com> wrote:

> There is no doubt a simple explanation here, but I'm still relatively 
> inexperienced and so I'm missing it.  I'm running this off localhost right 
> now so I can't give you a URI.  I'm using MySQL 3.23.51-nt and PHP 4.2.1.
> 
> I can't retrieve a text field even though I can retrieve all other fields 
> from the record.  But I *can* get it using MySQL Monitor, so I know it's there.
> ==============
> Here is the table definition:
> create table names(
> nameid int not null,
> key(nameid),
> lname varchar(15),
> fname varchar(25),
> note text);
> =============
> Here is the relevant segment from the retrieval code (with a lot of 
> debugging thrown in):
> $result=mysql_query($query) or die("Query #1 failed");
> 
> $numresults=mysql_num_rows($result);
> 
> $numnames=$numresults;
> 
>    for ($i=0;$i<$numnames;$i++){
>      $row_array=mysql_fetch_row($result);
> 
> // debugging
> $numfields=mysql_num_fields($result);
> echo "number of fields is $numfields<br />";
> for ($j=0;$j<$numfields;$j++) {
> $field=mysql_field_name($result,$j)." | ";
> echo $field;}
> echo "<br />";
> 
>      $lname[$i]=$row_array[0];
>      $fname[$i]=$row_array[1];
>      $note[i]=$row_array[2];
>      $date[$i]=$row_array[3];
>      $unitid[$i]=$row_array[4];
>      $address[$i]=$row_array[5];
> 
> //debugging
> echo 
> "###$lname[$i]|$fname[$i]|$note[$i]|$date[$i]|$unitid[$i]|$address[$i]###<br 
> />";}
> ====================
> Here is the output from this:
> lname | fname | note | dates | unitid | address |
> ###Southwell|Michael G||Jan 1983 -|106|81 South Road###
> =================
> So you can see that the fieldname has been retrieved but the contents of 
> the field haven't.  The contents themselves are simply this (it's test 
> data):  "He is creating the Historical Archives website database."  Anybody 
> have any ideas about what could be wrong here?
> 
> 
> Michael G. Southwell =================================
> DNEBA Enterprises
> 81 South Road
> Bloomingdale, NJ 07403-1419
> 973/492-7873 (voice and fax)
> southwell at dneba.com
> http://www.dneba.com
> ======================================================
> 
> 
> 



More information about the talk mailing list