关于Phplib中DB_Sql、Template的使用中的一些小疑问 最好的习惯是有始有终做程序也一样打开连接后自然要关闭才好.PHPLIB中最好还是用mysql_connecttemplate类不象数据库存储,在输出后没有必要销毁.为了增加可读性你可以试着把复杂的语句分开写但为了简洁还是写成一句比较好. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mysql_connect在页面结束后会自动关闭的 及时mysql_close有利于大量的并发访问。 phplib中的DB_Sql类中有没有负责关闭链接的函数?我指的是如何高效的使用DB_SQL,现在我这样使用:<?php /************************************************************** * 文件名: get_pwd2.php * 作 用: * 时 间: * * 版 权: * 作 者: * ****************************************************************/ require ("db_mysql.inc"); require ("template.inc"); $db = new DB_Sql(); $template = new Template("."); $db->connect(); $UserID = $_POST["UserID"]; $db->query("SELECT tb_UserInfo.vcPasswd, tb_User_Question.vcQuestion FROM tb_UserInfo, tb_User_Question WHERE tb_UserInfo.vcUserID = '$UserID' AND tb_User_Question.iQuestionID = tb_UserInfo.imQuestionID"); if(0 != $db->num_rows()) //存在这个用户 { $db->next_record(); $template->set_file("handle", "template/get_pwd2.ihtml"); $template->set_var("Question", $db->f("vcQuestion")); $template->set_var("UserID", $UserID); $template->set_var("Message", "请输入您提示问题的答案!"); $template->parse("out", "handle"); $template->p(out); } else //不存在此用户返回到第一步 { $template->set_file("handle", "template/get_pwd.ihtml"); $template->set_var("Message", "对不起,你输入的用户名不存在,请重试!"); $template->parse("out", "handle"); $template->p(out); }?>================================这里没有对数据库对象$db的关闭,也没有对实例化的$template进行销毁,这样我总感觉到有问题,怎么解决,还请大家多多发言 PHP编程 网页上获取不了中文 都是???,但是phpadmin里数据库显示中文 正则去掉<? ?>标签里的文字 这条语句哪出错了 帮我看一下这个mysql中的sql语句,不知道哪里出了问题就是执行不对 php 上传问题 是不是Apache配置的问题! 求大神帮忙php页面跳转问题 用php生成excel文件,为什么用样式单定好的数字格式在excel里却是"以文本形式存储的数字"? 请问关于文本框的问题 怎样得到一个月所包含的完整的周? 为什么我的session我自动清空? win2000下文件上传的问题
<?php
/**************************************************************
* 文件名: get_pwd2.php
* 作 用:
* 时 间:
*
* 版 权:
* 作 者:
*
****************************************************************/ require ("db_mysql.inc");
require ("template.inc"); $db = new DB_Sql();
$template = new Template("."); $db->connect(); $UserID = $_POST["UserID"];
$db->query("SELECT tb_UserInfo.vcPasswd, tb_User_Question.vcQuestion FROM tb_UserInfo, tb_User_Question WHERE tb_UserInfo.vcUserID = '$UserID' AND tb_User_Question.iQuestionID = tb_UserInfo.imQuestionID"); if(0 != $db->num_rows()) //存在这个用户
{
$db->next_record();
$template->set_file("handle", "template/get_pwd2.ihtml");
$template->set_var("Question", $db->f("vcQuestion"));
$template->set_var("UserID", $UserID);
$template->set_var("Message", "请输入您提示问题的答案!");
$template->parse("out", "handle");
$template->p(out);
}
else //不存在此用户返回到第一步
{
$template->set_file("handle", "template/get_pwd.ihtml");
$template->set_var("Message", "对不起,你输入的用户名不存在,请重试!");
$template->parse("out", "handle");
$template->p(out);
}
?>
================================
这里没有对数据库对象$db的关闭,也没有对实例化的$template进行销毁,这样我总感觉到有问题,怎么解决,还请大家多多发言