$db = mysql_select_db (' Test ', $conn);//Select Database
if (! $db) {
echo ' <hr/> ';
die (' ERROR: '. mysql_error ());
}else{
echo ' <hr/> ';
echo ' link database: '. $db;
}
/*
mysql_query () returns only a resource identifier for the Select,show,explain or DESCRIBE statement, FALSE if the query executes incorrectly.
for other types of SQL statements, mysql_query () returns TRUE on successful execution, and returns FALSE when an error occurs.
a return value of not FALSE means that the query is legitimate and can be executed by the server. This does not indicate any number of rows that are affected or returned. It is quite possible that a query execution succeeded but did not affect or return any rows.
*/
$sql = "SELECT * from user";
$result = mysql_query ($sql, $conn);//execute a MySQL query that automatically reads and caches the recordset. Use Mysql_unbuffered_query () if you want to run a non-cached query.
echo ' <hr/> ';
echo ' query result set: '. $result;//return Resource identifier
//echo ' <hr/> ';
//print_r (mysql_fetch_array ($result, MYSQL_ASSOC)); the//function takes one row from the result set as an associative array
//echo ' <hr/> ';
//print_r (mysql_fetch_array ($result, Mysql_num)); the//function takes one row from the result set as an array of numbers
//echo ' <hr/> ';
//print_r (mysql_fetch_array ($result)); the//function takes one row from the result set as an associative array and a numeric array, and the Mysql_fetch_row () function takes one row from the result set as an array of numbers
/*
The
mysql_fetch_array () function takes one row from the result set as an associative array, or an array of numbers, or both
returns the array generated from the rows obtained from the result set, or False if there are no more rows.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.