简单学习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);
?>