代码改变世界

随笔分类 -  web---php&Mysql

PHP中的$_SERVER['PATH_INFO']

2012-10-27 18:39 by youxin, 213 阅读, 收藏,
摘要: PHP中的全局变量$_SERVER['PATH_INFO']是一个很有用的参数,众多的CMS系统在美化自己的URL的时候,都用到了这个参数。对于下面这个网址:http://www.test.com/index.php/foo/bar.html?c=index&m=search我们可以得到$_SERVER['PATH_INFO']= ‘/foo/bar.html’,而此时$_SERVER['QUERY_STRING']= 'c=index&m=search';通 常,我们最初开始PHP程序编写的时候,都会使用诸如: 阅读全文

php输出Json

2012-10-21 23:07 by youxin, 5133 阅读, 收藏,
摘要: 从5.2版本开始,PHP原生提供json_encode()和json_decode()函数,前者用于编码,后者用于解码。json_encode — 对变量进行 JSON 编码,并返回 value 值的 JSON 形式,例如:1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);echo js... 阅读全文

simpleXML 解析xml

2012-10-19 23:39 by youxin, 415 阅读, 收藏,
摘要: 我们经常用到的一个函数simplexml_load_file(string$filename[,string$class_name= "SimpleXMLElement"[,int$options= 0[,string$ns= ""[,bool$is_prefix= false]]]] )Interprets an XML file into an object.Returns anobjectof classSimpleXMLElementwith properties containing the data held within the XML d 阅读全文

YQL 使用

2012-10-19 22:45 by youxin, 360 阅读, 收藏,
摘要: The Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL,apps run faster with fewer lines of code and a smaller network footprint.Yahoo! and other websites across the Internet make much of their structured data available to 阅读全文

用 PHP 读取和编写 XML DOM

2012-09-22 02:02 by youxin, 312 阅读, 收藏,
摘要: 使用 DOM 库读取 XML读取格式良好的 XML 文件最容易的方式是使用编译成某些 PHP 安装的文档对象模型 (DOM)库。DOM 库把整个 XML 文档读入内存,并用节点树表示它,如图 1 所示。<books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> <book> <author>J 阅读全文

MySQL索引

2012-09-19 13:30 by youxin, 322 阅读, 收藏,
摘要: Most MySQL indexes (PRIMARY KEY, UNIQUE, INDEX, and FULLTEXT) are stored in B-trees. http://dev.mysql.com/doc/refman/5.0/en/mysql-indexes.html 索引是快速搜索 阅读全文

Php header

2012-09-15 16:52 by youxin, 289 阅读, 收藏,
摘要: 设置清除缓存:<?php// Date in the pastheader("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Cache-Control: no-cache");header("Pragma: no-cache");?>http头信息header头信息的作用很多,最主要的有下面几个:1、跳转 当浏览器接受到头信息中的 Location: xxxx 后,就会自动跳转到 xxxx 指向的URL地址,这点有点类似用 js 写跳转。但是这个跳转只有浏览器知道,不管体 阅读全文

javascript和php传递数据

2012-09-02 21:13 by youxin, 7850 阅读, 收藏,
摘要: 1、php直接向JavaScript传递参数变量值本质,php向客户端显示第一变量值,为JavaScript代码,然后JavaScript代码发生作用。$one =1;alert();有时候会用这种形式。 举一个简单的例子来说明:如在页面a.html中用下面这句调用: 在b.php中有这样一段PHP代码: 当执行a.html文件时,就会调用b.php文件,并将b.php文件的输出作为JS语句来执行,所以此处会弹出一个提示框,内容为JS变量jstext的值,也就是在PHP文件中赋给jstext的值.小结: 在HTML里用JS 调用文件的方式调PHP文件,则PHP文件的输出将会被调用页... 阅读全文

MySQL数据库在指定位置增加字段

2012-09-01 23:56 by youxin, 4154 阅读, 收藏,
摘要: alter table table_name add column_name type 指定位置(注意很多代码add 后面还有column ,add column 同add一样,column可以省略)。如果不指定默认是在现有字段末尾插入。如果为First 则在开头插入。after field_name;在某个field后插入。删除字段alter table table_name drop (Column可要可不要) field_name 阅读全文

php插入日期到mysql失败

2012-09-01 23:07 by youxin, 3188 阅读, 收藏,
摘要: $today = date("m-d-Y");我在php里把日趋设置为以上格式,而我的mysql中如期类型是date;插入数据时始终插入失败,mysql data显示为0000-00-00;为什么?看下面文章:mySQL 日期类型:日期格式、所占存储空间、日期范围 比较。 日期类型 存储空间 日期格式 日期范围------------ --------- --------------------- ----------------------------------------- datetime 8 bytes ... 阅读全文

mysql 配置和php&mysql乱码问题

2012-09-01 21:13 by youxin, 409 阅读, 收藏,
摘要: $str = "CHN 软件开发有限公司,JPN ソフトウェア開発株"; 如果我们用 $query="insert into bookmarket(title) values('$str')"; 那么phpmyadmin显示是乱码的,为了解决在phpmyadmin的乱码问题,我们 在执行CRUD操作 阅读全文

PHP in_array array_search array_key_exists

2012-08-31 00:43 by youxin, 398 阅读, 收藏,
摘要: in_array checks if a value exists in an array 注意是值boolin_array(mixed$needle,array$haystack[,bool$strict=FALSE] )array_key_exists—Checks if the given key or index exists in the array 注意是键array_keys—Return all the keys or a subset of the keys of an array 返回特定值的key的数组arrayarray_keys(array$input[,mixed$ 阅读全文

php solutions:创建画廊

2012-08-24 23:32 by youxin, 407 阅读, 收藏,
摘要: 画廊原型如下:我们想要定义画廊的缩略图为两列。This is how it works. Let’s say you want two cells in each row. When the first cell is inserted,the counter is set to 1. If you divide 1 by 2 with the modulo operator (1%2), the result is 1.When the next cell is inserted, the counter is increased to 2. The result of 2%2 is 0. 阅读全文

php 表单加密验证

2012-08-23 17:05 by youxin, 788 阅读, 收藏,
摘要: SHA-1 is considered secure because it’s said to be computationally infeasible to work out theoriginal text or to find two sets of text that produce the same number. This means that even ifyour password file is exposed, no one will be able to work out what the passwords are. It alsomeans that you hav 阅读全文

php执行sql文件

2012-08-19 23:57 by youxin, 3234 阅读, 收藏,
摘要: <?php$hostname = 'localhost';$dbname = 'test';$username = 'root';$pw = 'vivian';$sqlfile = 'gb.sql';$sql = file_get_contents($sqlfile);echo($dbname);echo($sql);$conn = mysql_connect($hostname,$username,$pw) or die("无法连接数据库");mysql_select_db($dbnam 阅读全文

恢复数据库 — 把.frm,.myd,myi转换为.sql导入数据库

2012-08-19 20:04 by youxin, 784 阅读, 收藏,
摘要: *.frm是描述了表的结构,*.myd保存了表的数据记录,*.myi则是表的索引。1、把这些乱七八糟的文件一并复制到你的数据库的data下的数据库文件夹,直接就可以使用,无需转换为sql格式。前提是mysql的版本一致,字体一致。此方法简单快捷但不是没个人都能做到。其实根本就无法做到,除非你是在本地测试或者你是个人独霸一台服务器。像我这种用虚拟主机的,空间商一般是不会把数据库目录都给你让你去瞎折腾的,所以此方法基本无用,弃之。如果在主机商那里不行,就在本地安装MySQL数据库,将.frm,.myd,myi转换为.sql,再导入即可。 经过验证,确实可行。 阅读全文

php weblog 构建

2012-08-19 19:55 by youxin, 132 阅读, 收藏,
摘要: test 阅读全文

http header前为什么不能有空格

2012-08-19 19:22 by youxin, 1354 阅读, 收藏,
摘要: <?phpsession_start();?>在这个代码前如果有一个空格。When you make this tiny change, you are given a particularly venomous errormessage:Warning: session_start() [function.session-start]: Cannot send sessioncookie - headers already sent by (output started at/opt/lampp/htdocs/sites/startingchapter/sessions.php: 阅读全文

php 创建下载链接和中文文件名乱码解决

2012-08-18 21:30 by youxin, 2405 阅读, 收藏,
摘要: Creating a download linkA question that crops up( 突然出现)regularly in online forums is, How do I create a link to an image(or PDF file) that prompts the user to download it? The quick solution is to convert the fileinto a compressed format, such as ZIP. This frequently results in a smaller download, b 阅读全文

php 管理文件

2012-08-18 17:03 by youxin, 362 阅读, 收藏,
摘要: php 有很多文件处理函数file_get_contents 读取文件中的内容返回字符串。读取失败返回false。$contents = file_get_contents('C:/private/filetest01.txt');if ($contents === false) {echo 'Sorry, there was a problem reading the file.';}else {// convert contents to uppercase and displayecho strtoupper($contents);}为什么不用if(!$c 阅读全文
上一页 1 ··· 7 8 9 10 11 12 下一页