Common PHP code

Source: Internet
Author: User

<?

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 "<font size = 5 color = # FFFFFF> links or codes must be placed on the website to earn points </FONT> ";} 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 "<META HTTP-EQUIV = 'refresh' CONTENT = '3; URL = $ site_url/ptp. php'> </tr> ";
// Transfer to another webpage
Header ("Location: $ url ")
<Input type = "hidden" name = "id" value = "$ data [banner_id]"> // remember the variable
$ 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 <HTM
<Center> $ output1 [$ show5]
</Center>
HTM;
// Text link
If ($ textad = ""){
Session_register ('output ');
$ Textad = file ("text.txt ");}
For ($ I = 0; $ I <count ($ textad); $ I ++) print $ textad [$ I]. "<br> ";

?>

<Input type = "text" name = "helpor_net" size = "15" style = "border: 0"> // arrival time
<SCRIPT language = "javascript">
<! --
Var sec = 0;
Idt = window. setTimeout ("www_helpor_net ();", 1000 );
Function www_helpor_net ()
{
Sec ++;
If (sec = 60) {sec = 0 ;}
Helpor_net.value = sec + "seconds ";
Idt = window. setTimeout ("www_helpor_net ();", 1000 );
}
// --> </SCRIPT>
Weak window control
OnLoad = // activated when loading the page
Window. open (// reference Window object, Open method
'Blogchina. com', // URL of the window to be popped up
'Detail', // window name
'Toolbar = yes, // whether to display the toolbar of the browser (forward and backward buttons), Yes = display, No = Not Display
Location = yes, // whether to display the address bar, Yes = show, No = not show
Status = yes, // whether to display the status bar, Yes = show, No = not show
Menubar = yes, // whether to display the menu bar, Yes = show, No = not show
Scrollbars = yes, // whether to display the scroll bar, Yes = show, No = not show
Resizable = yes, // whether to allow drag and drop to change the size, Yes = display, No = Not Display
Width = 100, // The width of the pop-up window, in pixels, px
Height = 100 '// The height of the pop-up window, in pixels, px
)"

<Script>
<! --
Window. close ()
-->
</Script>

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.