mysql_field_flags() returned a space-separated set of flags for a field in PHP's removed MySQL extension. Current code should inspect table metadata directly or use MySQLi result-field metadata.
<?php
// Historical only.
$result = mysql_query('SELECT * FROM student');
$flags = mysql_field_flags($result, 0);
echo $flags;
?>
SHOW FULL COLUMNS FROM student;
The result exposes useful schema attributes such as Null, Key, Default, Extra, collation and privileges. For many tutorials this is more readable than decoding numeric flag bits.
<?php
$result = $connection->query(
'SELECT id, name, class, mark FROM student'
);
$field = $result->fetch_field_direct(0);
echo 'Name: ' . htmlspecialchars($field->name) . '<br>';
echo 'Flags bitmask: ' . $field->flags;
?>
SELECT
COLUMN_NAME,
IS_NULLABLE,
COLUMN_KEY,
COLUMN_DEFAULT,
EXTRA,
DATA_TYPE,
COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'sql_tutorial'
AND TABLE_NAME = 'student'
ORDER BY ORDINAL_POSITION;
Older versions of this page also used TYPE=MyISAM, integer display widths and each(). Those patterns are not needed for column-attribute inspection and are not carried forward as current examples.
Column metadata · Field/schema length · Field names · Field types · SHOW TABLES
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.