解析link_mysql的php版

yipeiwu_com6年前Mysql基础

复制代码 代码如下:

<?php
$str_sql_read="select count(*) as num from userinfo";
$str_sql_del="delete from userinfo where id =1";
$res =link_mysql("read",$str_sql_read);
$res_del =link_mysql("delete",$str_sql_del);
echo $res_del."<br/>";
while($row = mysql_fetch_assoc($res))
{
 echo "<font style='font-size:25px;color:red;'>".$row['num']."</font><br/>";
}

?>

<?php
function link_mysql($opt,$str_sql)
{
 $con = mysql_connect("localhost","root","root") or die ('Not connected : ' . mysql_error());
 mysql_set_charset("gbk",$con);
 //if you donot know how to use this function,find it defination;
 mysql_select_db("website",$con);
 switch($opt){
  case "read":
   $res =mysql_query($str_sql);
  break; 
  case "update":
  case "delete":
  case "insert":
   $res =mysql_query($str_sql);
  break;   
 }
 mysql_close();
 return $res;
}
?>

相关文章

windows下配置apache+php+mysql时出现问题的处理方法

windows: 安装apache,php,mysql 遇到的各种问题: 1. test.php运行不起,发现是httpd.conf中忘加AddType application/x-ht...

WampServer下安装多个版本的PHP、mysql、apache图文教程

WampServer下安装多个版本的PHP、mysql、apache图文教程

今天,我在调试一套PHP程序的时候,该程序中使用的某些函数在低版本中无法使用,所以只能在搞个高版本的php。 作为Web开发人员,在机器上安装不同版本的php,apache和mysql有...

mysql4.1以上版本连接时出现Client does not support authentication protocol问题解决办法

mysql4.1以上版本连接时出现Client does not support authentication protocol问题解决...

PHP+Mysql基于事务处理实现转账功能的方法

本文实例讲述了PHP+Mysql基于事务处理实现转账功能的方法。分享给大家供大家参考。具体如下: <?php header("Content-Type:text/h...

Mysql数据库操作类( 1127版,提供源码下载 )

Mysql.class.php 下载 复制代码 代码如下: <?php class Mysql { private $db_host; //主机地址 private $db_use...