$username="root";
$userpwd="";
$dbhost="localhost";
$dbname="0311db";
$link=mysql_connect($dbhost,$username,$userpwd);
if(!$link){
die("连接不成功");
}else
{
echo "连接成功 ";
if(mysql_select_db($dbname,$link))
{
echo "连接".$dbname."成功";
}
}
$sqlinsert="insert into usertable values(null,'dd',3,'dd')";
if(mysql_query($sqlinsert,$link))
{
echo "插入成功";
}
$sqlupdate="update usertable set username='wangman' where username='dd'";
if(mysql_query($sqlupdate,$link))
{
echo "修改成功";
}
$sqlupdate="delete from usertable where username='ssss'";
if(mysql_query($sqlupdate,$link))
{
echo "删除成功";
}
$sqlselect="select * from usertable";
echo $sqlselect."";
/*以下2句话就报错了*/
echo mysql_fetch_array($sqlselect);
echo mysql_num_rows($sqlselect);
mysql_query("set names gb2312");
mysql_close($link);
?>
展开