易截截图软件、单文件、免安装、纯绿色、仅160KB

php 数据库的封装类

 <?php
 class DB
 {
  private $link;
  function connectDB($dbhost, $dbuser, $dbpw, $dbname="", $pconnect = 1)
  {
   if($pconnect)
   {
    if(!$this->link = mysql_pconnect($dbhost, $dbuser, $dbpw))
    {
     $this->mysqlErrorMessage('Can not connect to MySQL');
    }
   }
   else
   {
    if(!$this->link = mysql_connect($dbhost, $dbuser, $dbpw))
    {
     $this->mysqlErrorMessage('Can not connect to MySQL');
    }
   }
   
   if(!empty($dbname))
   {
    mysql_select_db($dbname,$this->link);
   }
   mysql_query("set names 'gb2312'",$this->link);
  }
  
  function selectDB($dbName)
  {
   mysql_select_db($dbName,$this->link);
  }
  
  function query($sql)
  {
  
   if(!($query = mysql_query($sql,$this->link)))
   {
    $this->mysqlErrorMessage('SQL Error',$sql);
   } 
   return $query;
  }
  function mysqlErrorMessage($errorTitle,$errorContent)
  {
   echo $errorTitle." : ".$errorContent."<br>";
  }
    
  function fetchArray($query)
  {
   return mysql_fetch_array($query);
  }
  function fetchObject($query)
  {
   return mysql_fetch_object($query);
  }
  function closeDB()
  {
   mysql_clos


相关文档:

PHP Security for Deployers

PHP Security for Deployers
If you're a Developer
READ THIS and then work with your SysAdmins to step through any and all the layers of security designed to protect your apps.
Example:
Traffic must first pass through a SPI firewall (ensure that ONLY necessary ports/protocols are permitted; en ......

php分页TEST,自己写一下

<?
include 'conn.php';
$_pagenob=10; //每页规定的信息数目
//获取当前页
if(isset($_GET["page"]))
{
$_page = intval( $_GET['page'] );
}
else
{
$_page=1;
}
//查询数据总数
$_query="select count(*) as acount from news";
$_result=mysql_query($_query);
$_row=mysql_fetch_row($_result);
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号