Tag Archives: MySQL

mysql_info()

It returns information about the last query

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die( mysql_error());
mysql_select_db(“database_name”);
mysql_query(“INSERT INTO users (name) VALUES (‘PHP’)”);
echo mysql_info();
mysql_close();
?>

mysql_free_result()

Free result memory

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
$userQry = mysql_query(“SELECT * FROM users”);
mysql_free_result($userQry);
mysql_close();
?>

mysql_field_type()

It returns  the type of a field in a recordset

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
echo mysql_field_type($userQry=mysql_query(“SELECT * FROM users”),1);

?>

Output

string

mysql_field_table()

It returns the name of the table the specified field is in

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
echo mysql_field_table($userQry=mysql_query(“SELECT * FROM users”),1);

Output

users

mysql_field_seek()

It moves the result pointer to a specified field

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
mysql_field_seek($userQry=mysql_query(“SELECT * FROM users”),1);
print_r(mysql_fetch_field($userQry));
mysql_close();
?>

Output

stdClass Object
(
[name] => name
[table] => users
[def] =>
[max_length] => 4
[not_null] => 1
[primary_key] => 0
[multiple_key] => 0
[unique_key] => 0
[numeric] => 0
[blob] => 0
[type] => string
[unsigned] => 0
[zerofill] => 0
)

mysql_field_name()

It returns the name of a field in a recordset

Example

<?php
mysql_connect(“localhost”, “root”, “phpcode”) or die(mysql_error());
mysql_select_db(“database_name”);
echo “<pre>”;
echo mysql_field_name(mysql_query(“SELECT * FROM users”),1);
?>

Output

name