PHP mysql_field_type() Function Example

PHP mysql_field_type() Function Example


Posted in : PHP Posted on : February 19, 2011 at 5:28 PM Comments : [ 0 ]

The mysql_field_type() function is used to get the type of the field in a recordset.

PHP mysql_field_type() Function Example:

The mysql_field_type() function is used to get the type of the field in a recordset. The mysql_field_type() function returns the type of the specified field on success or false for failure.

Example:

<?php
$connection = mysql_connect("localhost","root","root");
if (!$connection)
{
die('PHP Mysql database connection could not connect : ' . mysql_error());
}

$db_selected = mysql_select_db("php_mysql",$connection);

$sql_query = "SELECT * from user";
$result = mysql_query($sql_query, $connection);

$type1 = mysql_field_type($result, 0);
$type2 = mysql_field_type($result, 1);

echo "First field type is : " . $type1 . "<br/>";
echo "Second field type is : " . $type2;

mysql_close($connection);
?> 

The database 'user' table is:

In this example we have used mysql_field_type() function that have two parameters first is record set and other is field to start returning.

Output:

First field type is : int
Second field type is : string

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics