About php operating mysql

不言
Release: 2023-03-23 22:08:01
Original
1329 people have browsed it

The content of this article is about php operating mysql, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

header("Content-type: text/html; charset=utf-8");
$db_config = array(
		"host"=>"localhost",
		"db_user"=>"root",
		"db_password"=>"hxsbhxsb",
		"db_name"=>"chenchen"
	);
$link = @mysql_connect($db_config["host"],$db_config["db_user"],$db_config["db_password"]);
if($link){
	// echo "数据库连接成功!";
}else{
	die("数据库连接失败,请与管理员联系!");
}
mysql_select_db($db_config["db_name"]);
mysql_query("set names utf8");
$res = mysql_query("select * from tab3");
if($res){
	$row = mysql_fetch_row($res);
	var_dump($row);
	$row = mysql_fetch_row($res);
	var_dump($row);
}else{
	echo "错误信息".mysql_error();
}
Copy after login

mysql_num_rows(result) //Return the result set Number of rows
mysql_num_fields(result) //Returns the number of columns in the result set
mysql_field_name(result, $i) //Returns the name of the i-th field in the result set

Related recommendations:

Several ways to convert PHP strings into PHP arrays

Sharing of PHP commands to operate redis


The above is the detailed content of About php operating mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!