Home > php教程 > php手册 > body text

简单学习PHP向MYSQL中插入数据的代码

WBOY
Release: 2016-06-13 10:29:22
Original
1205 people have browsed it

简单学习PHP向MYSQL中插入数据的代码

$dbhost = localhost;
$dbuser = webjxcom; //你的mysql用户名
$dbpass = 123456; //你的mysql密码
$dbname = database; //你的mysql库名

//连接本地数据库
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
if ($conn) {
echo "连接数据库成功";
} else {
echo "连接数据库失败";
}
//打开数据库
mysql_select_db($dbname,$conn);
//插入数据
$sql="insert into test(test) values(ddddddd)";
$result=mysql_query($sql,$conn)or die(mysql_error());

echo "打开数据库";
//关闭数据库
mysql_close($conn);
?> 


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 Recommendations
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!