Common PHP code

Source: Internet
Author: User
Common PHP code
Add ob_start () to the header file when you cannot switch
// Write global variables
Session_start (); // after data cannot be submitted, add: extract ($ _ POST); extract ($ _ GET); extract ($ _ SESSION );

Session_register ('PT _ usr_nm '); // write the global variables of the browser.

// Connect to the 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 "cannot connect to the 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); // gets the number of returned columns. Can be used to check whether any data meets the conditions

// Count the qualified quantity
$ 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']; // Obtain the origin site
If ($ a = "") {echo "links or code must be placed on the website to get points";} else {
$ B = parse_url ($ a); // Obtain the origin site data
$ B [host]; // Obtain the domain name of the origin site
// Automatically refresh in 3 seconds
Print" ";
// Transfer to another webpage
Header ("Location: $ url ")
// Remember variables
$ A = number_format ($ money * 0.00001, 6) // format the data, retain 6 decimal places
// Cycle 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
";

?>

// Arrival time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.