Home  >  Article  >  Backend Development  >  Common PHP codes_PHP tutorial

Common PHP codes_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:00:47744browse


Use ob_start(); when redirection is not possible; add it to the header file
// Write global variables
session_start(); // If data cannot be submitted, add: extract($_POST );extract($_GET);extract($_SESSION);

session_register('pt_usr_nm');//Write to browser global variables

//Connect to MySQL database
function dbconnect()
{
global $site_domain,$db_host,$db_name,$db_user,$db_pass;
if($link = mysql_connect($db_host,$db_user,$db_pass))
{
$res=mysql_select_db($db_name) or die(mysql_error());
if($res)
return $link;
}
else print "Unable to connect to database";
}
//Disconnect the MySQL database
function dbclose($link)
{
global $link;
if(mysql_close($link))
{}
}
$quer8 = "select url,image from cpc_ad where id='$cid'";//Database call
$sult8 = mysql_query($quer8);//Send a query string.
$bank8 = mysql_fetch_array($sult8);//Return array data.
$no=mysql_num_rows($sult8);//Get the number of returned columns.Can be used to check whether there is data that meets the conditions

//Count the number of qualified data
$qrym="select count(*) from a_cip where TO_DAYS(date)=TO_DAYS(NOW())-1 ";
if($mres=mysql_query($qrym))
{
$mres=mysql_fetch_array($mres);
$membercount11=$mres[0];
}
$qrym="select count(*) from a_cip where ipuse='' and time_to_sec(date)>time_to_sec(NOW())-1800 and TO_DAYS(date)=TO_DAYS(NOW())";
if ($mres=mysql_query($qrym))
{
$mres=mysql_fetch_array($mres);
$membercount1=$mres[0];
}

// Insert new database data
$query = "INSERT INTO ptr_ptoc_clicks SET mem_id = '$pt_usr_nm', banner_id = $bank5[banner_id], click_date = now(),ip='$ip'";
mysql_query($ query);
//Modify database data
$query = "UPDATE ptr_member_clicks SET self_banner_click =self_banner_click+$clamt WHERE mem_id = '$pt_usr_nm'";
mysql_query($query);

$a=$_SERVER['HTTP_REFERER'];//Get the source URL
if ($a=="") { echo " The link or code must be placed on the website You can get points";} else{
$b=parse_url($a);//Get the source URL data
$b[host];//Get the source URL domain name
//Automatically refresh in 3 seconds
print"";
/ /Transfer to other web pages
header("Location:$url")
// Remember variables
$a=number_format($money*0.00001,6)//Format data, keep 6 decimal places
//Loop flag
if ($output5==""){
session_register(' output5');
$output1=file("qizi.txt");
}
$show5=rand(0,count($output1)-1);
session_register('show5' );
print <<

$output1[$show5]

HTM;
//Text link
if ($textad==""){
session_register('output');
$textad=file("text.txt");}
for($i=0;$i
";

?>

//Time to mark