W3Schools.com

PHP mysql_field_flags() Function


PHP MySQL Reference Complete PHP MySQL Reference

Definition and Usage

The mysql_field_flags() function returns the flags of a field in a recordset.

This function gets field data from the mysql_query() function and returns a string on success, or FALSE on failure or when there are no more rows.

Possible return values:

  • auto_intcrement - 1 if AUTO_INCREMENT is set
  • binary - 1 if the field has the BINAR attribute set
  • blob - 1 if the field is a BLOB
  • enum - 1 if the field is an ENUM field
  • multiple_key - 1 if the field is a non-unique key
  • not_null - 1 if the field cannot be NULL
  • primary_key - 1 if the field is a primary key
  • timestamp - 1 if the field is a timestamp field
  • unique_key - 1 if the field is a unique key
  • unsigned - 1 if the field is unsigned
  • zerofill - 1 if the field is zero-filled

Syntax

mysql_field_flags(data,field_offset)

Parameter Description
data Required. Specifies which data pointer to use. The data pointer is the result from the mysql_query() function
field_offset Required. Specifies which field to start returning. 0 indicates the first field


Tips and Notes

Tip: You can break the returned string into an array by using explode().


Example

<?php
$con = mysql_connect("localhost", "peter", "abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("test_db",$con);

$sql = "SELECT * from Person";
$result = mysql_query($sql,$con);

$flags = mysql_field_flags($result, 0);
echo $flags;

mysql_close($con);
?>

The output of the code above could be:

not_null primary_key auto_increment


PHP MySQL Reference Complete PHP MySQL Reference

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Best Website Templates Top CSS Templates
CREATE HTML Websites
EASY WEBSITE BUILDER
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE