文章分类 -  PHP/MYSQL

摘要:<h1>Employee listing</h1><form method="post" ><p>Enter Department ID:<input type="text" name="dept_id" size="4"><input type="submit" name="submit" value="submit"><p></form><?php$h 阅读全文
posted @ 2012-02-13 19:22 rob_2010 阅读(525) 评论(0) 推荐(0)
摘要:<?phpClass DB {private $link_id; private $handle; private $is_log; private $time;//构造函数 public function __construct() { $this->time = $this->microtime_float(); require_once("config.db.php"); $this->connect($db_config["hostname"], $db_config["username"], $db_ 阅读全文
posted @ 2012-02-13 13:35 rob_2010 阅读(233) 评论(0) 推荐(0)
摘要:// 配置文件<?php$db = array( 'host'=>'localhost', 'user'=>'root', 'password'=>'', 'database'=>'test',) ?>//php 类<?phpclass db { public $conn; public static $sql; public static $instance=null; private function __construc 阅读全文
posted @ 2012-02-12 21:44 rob_2010 阅读(219) 评论(0) 推荐(0)
摘要:<?phpclass Mcrypt{ /** * 解密 * * @param string $encryptedText 已加密字符串 * @param string $key 密钥 * @return string */ public static function _decrypt($encryptedText,$key = null) { $key = $key === null ? Config::get('secret_key') : $key; $cryptText = base64_decode($encryptedText); $ivSize = mcry 阅读全文
posted @ 2012-02-12 01:47 rob_2010 阅读(111) 评论(0) 推荐(0)
摘要:/******@dir - Directory to destroy*@virtual[optional]- whether a virtual directory*/function destroyDir($dir, $virtual = false){$ds = DIRECTORY_SEPARATOR;$dir = $virtual ? realpath($dir) : $dir;$dir = substr($dir, -1) == $ds ? substr($dir, 0, -1) : $dir;if (is_dir($dir) && $handle = opendir( 阅读全文
posted @ 2012-02-12 01:45 rob_2010 阅读(178) 评论(0) 推荐(0)
摘要:<?php$m = mysql_connect('127.0.0.1','root','') or die("Invalid query: " . mysql_error());mysql_select_db('discuz', $m) or die("Invalid query: " . mysql_error());$handle = fopen("aa.txt", "r");while (!feof($handle)) { $buffer 阅读全文
posted @ 2012-02-12 01:43 rob_2010 阅读(393) 评论(0) 推荐(0)
摘要:1. 发送短信调用 TextMagic API。// Include the TextMagic PHP librequire('textmagic-sms-api-php/TextMagicAPI.php');// Set the username and password information$username = 'myusername';$password = 'mypassword';// Create a new instance of TM$router = new TextMagicAPI(array('username 阅读全文
posted @ 2012-02-12 01:42 rob_2010 阅读(173) 评论(0) 推荐(0)
摘要://file_get_contents<?php $url = "http://www.120sc.com"; $contents = file_get_contents($url); //如果出现中文乱码使用下面代码 mb_convert_string();//$getcontent = iconv("gb2312", "utf-8",$contents); echo $contents; ?>//curl<?php $url = "http://www.120sc.com"; $ch = cu 阅读全文
posted @ 2012-02-12 00:44 rob_2010 阅读(105) 评论(0) 推荐(0)
摘要:<?phpunset($username);if ($_COOKIE['login']) { list($c_username,$cookie_hash) = split(',',$_COOKIE['login']); if (md5($c_username.$secret_word) == $cookie_hash) { $username = $c_username; } else { print "You have sent a bad cookie."; }}if ($username) { print &quo 阅读全文
posted @ 2012-01-17 15:02 rob_2010 阅读(228) 评论(0) 推荐(0)
摘要:/* 记录浏览历史 */if (!empty($_COOKIE['history'])){ if(stripos($_COOKIE['history'].',',$goods_id.',')===false){ $history = explode(',', $_COOKIE['history']);array_unshift($history, $goods_id); //入栈 while (count($history) > 5) //大于容器容量 { array_pop($history 阅读全文
posted @ 2012-01-17 14:08 rob_2010 阅读(143) 评论(0) 推荐(0)
摘要:setcookie(PHP3,PHP4,PHP5)setcookie-- 发送一个 cookie 信息说明boolsetcookie( string name [, string value [, int expire [, string path [, string domain [, bool secure]]]]] )setcookie()定义一个和其余的 HTTP 标头一起发送的 cookie。和其它标头一样,cookie 必须在脚本的任何其它输出之前发送(这是协议限制)。这需要将本函数的调用放到任何输出之前,包括 <html> 和 <head> 标签以及任何空 阅读全文
posted @ 2012-01-16 19:52 rob_2010 阅读(128) 评论(0) 推荐(0)
摘要:<!DOCTYPE html><html><title>基本语法</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><body><a href="../index.php">返回首页</a><hr></hr><b>HTTP Cookies</b><?php #from:http://www 阅读全文
posted @ 2012-01-16 14:30 rob_2010 阅读(124) 评论(0) 推荐(0)
摘要:因为下载下来的压缩包里面有包含很多在我们使用时,用不到的,不删除也行。看个人喜好下面以PHP为例,进行程序瘦身删除所有”_”开头的文件和文件夹删除FCKeditor的目录下:fckeditor.afpfckeditor.aspfckeditor.cfcfckeditor.cfmfckeditor.lassofckeditor.plfckeditor.pyhtaccess.txtlicense.txt删除语言包editor\lang中除中文和英文以外的语言删除skin目录下除默认皮肤以外的文件夹filemanager/browser/default/connectors/目录下除php以外的文件 阅读全文
posted @ 2012-01-16 11:50 rob_2010 阅读(134) 评论(0) 推荐(0)
摘要:php5.3.x不再支持php_mssql.dll 拓展库了,及时使用php5.2.x中的php_mssql.dll 也无法使用。微软专门为PHP出了个SQL Server的扩展(Windows版本的),对于Windows下使用php开发SQL Server应用来说,这个扩展有利于利用SQL Server来开发php平台连接sql server数据库管理系统。PHP5.2.x本身有个php_mssql.dll的扩展用来连接Sql server,但是貌似这个dll只是用来连接低版本 Sql server的(2000以下版本),在Sql server 2005及以上版本则根本无法使用mssql_. 阅读全文
posted @ 2012-01-04 19:28 rob_2010 阅读(224) 评论(0) 推荐(0)
摘要:$conn=@mssql_connect("127.0.0.1","sa","database") or die("连接错误");mssql_select_db("test") or die("没有此数据库");$sql="select * from login";$result=mssql_query($sql);while($row=mssql_fetch_assoc($result)){echo $row['id']." & 阅读全文
posted @ 2012-01-04 19:27 rob_2010 阅读(95) 评论(0) 推荐(0)
摘要:由于某原因,需要用php连接mssql,又由于某些原因需要调用mssql的存储过程(观众:靠!哪来的这么多原因)。这里给出实现方法,注释就不多写了,详见php参考手册sql server存储过程CREATEPROCEDUREProcTest@idint,@namevarchar(30)outputASselect@name=usernamefrommm_userwhereid=@idselect*frommm_userphp实现代码:<?php$userId=2;//testparameter$userName;//testreturnvalue$link=mssql_connect(& 阅读全文
posted @ 2012-01-04 19:25 rob_2010 阅读(770) 评论(0) 推荐(0)
摘要:require()和include()有许多相似之处,也有些不同。理解它们的不同点非常重要,否则很容易犯错误。我把这两个语句放在一起介绍,读者可以比较学习。1.require()语句require()语句用于指定的文件代替语句本身,就象C语言中的include()语句一样。如果php配置文件php.ini中的URL fopen wrappers是打开的(默认情况下是打开的),就可以使用URL来指定文件的位置从而实现远程文件的调用。有一点就是使用require()和include()语句时要特别的注意。那就是在被包含的文件中,处理器是按照html模式来解释其中的内容的,处理完被包含的内容后又恢复 阅读全文
posted @ 2012-01-04 14:51 rob_2010 阅读(136) 评论(0) 推荐(0)
摘要:在学习PHP100中遇到了一个这样的提示:Notice: Undefined index: submit inF:\127.0.0.10\add.phpon line5如下图所示:PHP中的代码如下(我还没有完全写好哈`呵呵```):<?PHPinclude("conn.php");if($_POST['submit']){$sql="insert into message(id,user,title,content,lastdate) values ('','$_POST[user]','$_POST 阅读全文
posted @ 2012-01-02 14:31 rob_2010 阅读(200) 评论(0) 推荐(0)
摘要:http://shuai.be/archives/php-undefined-index/平时用$_GET[‘xx’] 取得参数值时,如果之前不加判断在未传进参数时会出现这样的警告:PHP Notice: undefined index xxx虽然可以通过设置错误显示方式来隐藏这个提示,但是这样也有隐患,就是在服务器的日志中会记录这些提示,导致日志文件异常庞大!下面是引用网上流行的解决方法:首先,这个不是错误,是warning。所以如果服务器不能改,每个变量使用前应当先定义。方法1:服务器配置修改修改php.ini配置文件,error_reporting = E_ALL & ~E_NO 阅读全文
posted @ 2012-01-02 14:28 rob_2010 阅读(142) 评论(0) 推荐(0)
摘要:mysql是我以前学习和练习所使用的数据,现在在工作中也在使用,之前公司里用oracle,我在做自己的东西的时候觉得用oracle太不方便,于是就找了mysql(当时也考虑过sqlserver,觉得还是没有mysql小巧),从那时起我就开始接触下面所说的几种mysql客户端工具了。 我接触的mysql客户端工具一共有4个,mysqlfront, sqlyog, mysqlbrowser, ems mysql manager,其中mysqlbrowser是我最早使用的一个mysql客户端工具(一年前),当时是在一个自己接的交友网站中使用mysql,于是就找到了这个mysqlbrowser,mys 阅读全文
posted @ 2011-12-31 16:54 rob_2010 阅读(148) 评论(0) 推荐(0)