List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:September 18 1999 6:12pm
Subject:Re: in php: mysql_list_fields doesn't
View as plain text  
At 12:54 PM -0500 9/18/99, Seth Tager wrote:
>Thanks Paul,
>
>I tried the code you sent and it still doesn't work.
>Here is a small example. It first tries to print out just the
>column info for a table, and then, to demonstrate that the table
>exists, it prints out info from one of the columns of the same
>table. Maybe
>
>    $db = mysql_connect("localhost:8001", "mylogin", "mypasswd");
>    $select_ok = mysql_select_db("mydb",$db);
>    $tableName = "items";
>
>    // try to print field info from table
>    $result = mysql_list_fields ("mydb", $tableName)
>        or die ("Query failed");
>    print ("member table column information:<BR>\n");
>    for ($i = 0; $i < mysql_num_fields ($result); $i++)
>    {
>        printf ("column %d:", $i);
>        printf (" name %s,\n", mysql_field_name ($result, $i));
>        printf (" len %d,\n", mysql_field_len ($result, $i));
>        printf (" type %s,\n", mysql_field_type ($result, $i));
>        printf (" flags %s\n", mysql_field_flags ($result, $i));
>        print "<BR>\n";
>    }
>
>    // print some data from all records in the table
>    $queryResult = mysql_query ("select * from $tableName")
>        or die ("Query failed");
>    print ("query information:<BR>\n");
>    while ($myrow = mysql_fetch_array($queryResult)) {
>        echo $myrow[itemName] . "<br>";
>    }
>
>and here's the output. Notice that "member table info" is empty while
>"query info" is not.
>
>member table column information:
>query information:
>Long Sleeve Tee
>Long Sleeve Crew
>Short Sleeve Crew
>Short Sleeve Tee
>tights1
>tights2
>tech1vest
>tech2vest
>simplevest
>tech1pullover
>tech2pullover
>simplepullover
>simplepant
>pants1
>pants2
>sweatshirt
>hoodsweat
>
>Seth

Huh.  Well, my code works for me (of course).  What versions of
stuff do you have?  I'm running MySQL 3.23.3, Apache 1.3.6, PHP 3.0.12.


--
Paul DuBois, paul@stripped
Thread
in php: mysql_list_fields doesn'tSeth Tager18 Sep
  • Re: in php: mysql_list_fields doesn'tPaul DuBois18 Sep
    • Re: in php: mysql_list_fields doesn'tSeth Tager18 Sep
      • Re: in php: mysql_list_fields doesn'tPaul DuBois18 Sep
        • Re: in php: mysql_list_fields doesn'tSeth Tager18 Sep
          • Re: in php: mysql_list_fields doesn'tMichael Widenius19 Sep
            • Re: in php: mysql_list_fields doesn'tSeth Tager20 Sep