//建立数据库连接,数据库地址127.0.0,用户名root,密码root
$dbConn = mysql_connect('127.0.0.1', 'root', 'root');
mysql_query('set names utf8'); //指定数据字符集
mysql_select_db('test', $dbConn); //指定数据库test //增
$insertSql = 'insert into users(uname, email) values("刘强东", "liuqiangdao@jd.com")';
var_dump($insertSql);
$result = mysql_query($insertSql, $dbConn); //成功返回true,失败返回false //删
$deleteSql = "delete from users where id=2";
$result = mysql_query($deleteSql, $dbConn); //改
$updateSql = 'update users set email="liuqiangdong@163.com" where uname="刘强东"';
$result = mysql_query($updateSql, $dbConn); //查
$strSql = 'select * from users';
$result = mysql_query($strSql, $dbConn);
//$result数据类型不能直接显示,要使用mysql_fetch_array()一行一行的取出
while($row = mysql_fetch_array($result)){
var_dump($row);
} //关闭连接
mysql_close($dbConn);