note 19765 modified in function.mysql-fetch-field by danbrown

From: Date: Sat, 20 Jun 2009 02:26:30 +0000
Subject: note 19765 modified in function.mysql-fetch-field by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157167@lists.php.net to get a copy of this message
The field type returns what PHP classifies the data found in the field, not how it is stored in the database; use the following example to retrieve the MySQL information about the field.... <?php $USERNAME = ''; $PASSWORD = ''; $DATABASE = ''; $TABLE_NAME = ''; mysql_connect('localhost', $USERNAME, $PASSWORD) or die ("Could not connect"); $result = mysql_query("SHOW FIELDS FROM $DATABASE.$TABLE_NAME"); $i = 0; while ($row = mysql_fetch_array($result)) { echo $row['Field'] . ' ' . $row['Type']; } ?> --was-- The field type returns what PHP classifies the data found in the field, not how it is stored in the database; use the following example to retrieve the MySQL information about the field.... $USERNAME = ''; $PASSWORD = ''; $DATABASE = ''; $TABLE_NAME = ''; mysql_connect('localhost', $USERNAME, $PASSWORD) or die ("Could not connect"); $result = mysql_query("SHOW FIELDS FROM $DATABASE.$TABLE_NAME"); $i = 0; while ($row = mysql_fetch_array($result)) { echo $row['Field'] . ' ' . $row['Type']; } http://php.net/manual/en/function.mysql-fetch-field.php

« previous php.notes (#157167) next »