Practicing the piano when the riff called a small piece of music, then I define the program's riff is a small piece of the program, put some of these days to write their own, later also long-term update, as their own accumulation and future programming reference.
1. Format URL, if no HTTP headers inserted HTTP header
<?php//add http head to URL function addhttphead (& $s) {$exist = Strstr ($s, "http://"); if (! $exist) $s = "htt p://". $s; }?>
2. Link MySQL Database
<?php $conn =mysql_connect ("IP", "username", "password"); mysql_select_db ("database name");?>
3. SELECT MySQL Database
$exec = "SELECT * from movie"; $result = mysql_query ($exec); while ($rs =mysql_fetch_object ($result)) {//access to each record, such as Echo $rs->name;}
4. WINDOWS Named pipe Communications (pipelines are established by other processes)
function Sendtoclient ($msg) {$fp = @fopen ("////.//pipe//tongxun", ' w+r+b '), @fwrite ($fp, $msg),//write $result = @fread ($fp, 256)//Read fclose ($FP); }
5. Judge check box result
function Isselect ($index, $select _tag) {for ($i =0; $i <count ($select _tag); $i + +) {if ($index = = $select _tag[$i]) return TRUE; return FALSE; }
6. Page token generation and processing
Generate page tokens to prevent duplicate submission of forms $pagecode = Mt_rand (0,10000000); $_session[' Code ' = $pagecode; ...///To obtain a token to operate the page if ($_session[' code '] = = $_post[' Pagecode ']) {//token meets} else//token not conforming
7. JSP take form content
Note here that IE has a innerhtml trap, the result needs to trim a bit.
$data = document.all. Table Id.rows (line number). Cells (column number). InnerHTML;