(1) 建立连接
(2)选择数据库
(3) 执行SQL语句
(4) 关闭数据库连接
<?php
$link=mysql_connect("localhost","root","root");
if($link)echo"连接数据库成功!";
else echo"连接数据库失败!";
$sele=mysql_select_db("com");
if($sele) echo"选择数据库成功!";
else echo"选择数据库失败!";
$exec="select * from test";
$result=mysql_query($exec);
echo $result."<br>";
$exec="insert into test values(null,'Janel',23,'female','wenmin cun 34#')";
$result=mysql_query($exec);
echo $result."<br>";
mysql_close();
?>
(2)选择数据库
(3) 执行SQL语句
(4) 关闭数据库连接
<?php
$link=mysql_connect("localhost","root","root");
if($link)echo"连接数据库成功!";
else echo"连接数据库失败!";
$sele=mysql_select_db("com");
if($sele) echo"选择数据库成功!";
else echo"选择数据库失败!";
$exec="select * from test";
$result=mysql_query($exec);
echo $result."<br>";
$exec="insert into test values(null,'Janel',23,'female','wenmin cun 34#')";
$result=mysql_query($exec);
echo $result."<br>";
mysql_close();
?>