sqlite 数据库连接类

 */
class db_class {
 var $conn=null;
 var $querynum = 0;

 /**
  * 数据库连接,返回数据库连接标识符
  *
  * @param string $ 数据库服务器主机
  * @param string $ 数据库服务器帐号
  * @param string $ 数据库服务器密码
  * @param string $ 数据库名
  * @param bool $ 是否保持持续连接,1为持续连接,0为非持续连接
  * @return link_identifier $dbuser, $dbpw, $dbname,
  */
 function connect($dbhost, $pconnect = 0) {
  $error = '';
  $func = $pconnect == 1 ? 'sqlite_popen' : 'sqlite_open';
  if (!$this -> conn = $func($dbhost, 0666, $error)) {
   $this -> halt($error);
  }

阅读全文

ip网段转换程序(把ip地址转换成相对就的整数)

mysql教程_connect('localhost','root','root');
mysql_select_db('dfd');

$array = file("ip.txt");
foreach( $array as $k  )
{
 list ($ip,$s) = explode('/',$k);
 $ipe = str_replace('.0','.255',$ip);
 $ipint = iptoint($ip);
 $ipinte = iptoint($ipe); 
 //echo iptoint($ip) .'-'.iptoint($ipe),'<br />';
 $s = array($ip,$ipe,$ipint,$ipinte);
 save($s);
}

阅读全文

php $HTTP_COOKIE_VARS 实例投票资料限制

if ($http_cookie_vars["vote"]) {
 echo "<script>alert('您已经投过票了,请不要重复投票');history.back();</script>";
 exit;
}
$vcount=$_post["vcount"];
$lld=$_post["jump"];
$tys=$_post["tys"];
if (!$vcount) {
 echo "<script>alert('您还没有选择任何投票项目');history.back();</script>";
 exit;
}
$db=@mysql_connect("localhost","root","root") or die("数据库教程连接失败");
mysql_select_db("vote",$db);
if ($vcount&&$lld) {
 if ($tys=="1") {
  $sql="update vote set vcount=vcount+1 where id=$vcount";
  $result=mysql_query($sql,$db);
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
 else {
  for ($i=0;$i<sizeof($vcount);$i++) {
   $sql1="update vote set vcount=vcount+1 where id=$vcount[$i]";
   $result1=mysql_query($sql1,$db);
  }
  setcookie("vote","vote",time()+3600);
  echo "<script>alert('投票成功!');location.href='vote.php?id=$lld';</script>";
 }
}

阅读全文

php zend 配置,数据库加,模板引擎设置

今天我们来讲一下关于php mvc模板的zend使用方法与配置实例,这是一款从zend加载 config文件到加载数据库 getinstance()方法用来获取前端控制器实例 加载smarty模板插件等简单的配置方法。
*/
 //指明引用文件的路径
    set_include_path('.' .
    path_separator . './libary/'.           //指定zend所在目录
    path_separator . './application/models/'. //指定model所在目录
    path_separator . './libary/smarty/'.   
    path_separator . get_include_path());

阅读全文

正则表达式匹配字母 汉字 空格

验证由26个英文字母组成的字符串:^[a-za-z]+$
验证由26个大写英文字母组成的字符串:^[a-z]+$
验证由26个小写英文字母组成的字符串:^[a-z]+$
验证由数字和26个英文字母组成的字符串:^[a-za-z0-9]+$
验证由数字、26个英文字母或者下划线组成的字符串:^w+$
验证用户密码:^[a-za-z]w{5,17}$ 正确格式为:以字母开头,长度在6-18之间,只能包含字符、数字和下划线。
验证是否含有 ^%&',;=?$" 等字符:[^%&',;=?$"]+
验证汉字:^[u4e00-u9fa5],{0,}$
验证email地址:^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$
验证interneturl:^http://([w-]+.)+[w-]+(/[w-./?%&=]*)?$ ;^[a-za-z]+://(w+(-w+)*)(.(w+(-w+)*))*(?s*)?$
验证电话号码:^((d{3,4})|d{3,4}-)?d{7,8}$:--正确格式为:xxxx-xxxxxxx,xxxx-xxxxxxxx,xxx-xxxxxxx,xxx-xxxxxxxx,xxxxxxx,xxxxxxxx。
验证身份证号(15位或18位数字):^d{15}|d{}18$
验证一年的12个月:^(0?[1-9]|1[0-2])$ 正确格式为:"01"-"09"和"1""12"
验证一个月的31天:^((0?[1-9])|((1|2)[0-9])|30|31)$    正确格式为:01、09和1、31。

阅读全文

php mysql 数据库备份程序

?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link type="text/css教程" rel="stylesheet" href="common/control.css">
<script type="text/网页特效" language="javascript" src="common/admin.otable.js"></script>
<script type="text/javascript" language="javascript" src="common/include.func.js"></script>
<title>数据管理</title>
<style type="text/css">
span {padding-left:8px;}
</style>
</head>

阅读全文

php文件上传程序(支持缩略图)(1/2)

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>上传文件程序</title>
<style type="text/css教程">
*{
 font-size:12px;
 margin:0; padding:0;
}
a:link,a:visited{
 text-decoration:none;
 color: #393
}
a:hover{
 text-decoration:underline;
 color:#0033cc
}
input.text{
 border:1px solid #ccc;height:22px;line-height:22px;padding-left:5px;background:#fff;width:274px;
}
input.button{
 background:#fff url(http://pic4.phprm.com/2010/09/11/button.jpg);border:1px solid #9ea9c5;padding:2px 2px 0px 2px;margin-left:4px; margin-right:4px;
}
</style>
<script language=网页特效>
function check()
{
 var strfilename=document.myform.upfile.value;
 if (strfilename=="")
 {
     alert("请选择要上传的文件");
  document.myform.upfile.focus();
     return false;
   }
}
</script>
</head>

阅读全文