PHP implements multi-machine interlock instances by inserting MySQL data, mysql instance _php tutorial

Source: Internet
Author: User

PHP implements multi-machine interlock instances by inserting MySQL data, mysql instance


In this paper, the example of PHP through the insertion of MySQL data to achieve multi-machine interlock method, share to everyone for your reference. The implementation method is as follows:

You can add a general lock before executing the process, the shell shackle function is as follows, if successful, it returns 0, otherwise it returns a non-0 value:

Copy the Code code as follows: function Get_lock ()
{
Local dataid= "${1}"
Local datadate= "${2}"

Local sql= "Insert Intot_trans_lock
(Dataid, Datadate) VALUES (' ${dataid} ', ' ${datadate} '); "
Echo ${sql} | ${db_public}

Return $?
}

Release a lock when execution fails or ends
Copy the Code code as follows: function Free_lock ()
{
Local dataid= "${1}"
Local datadate= "${2}"
Local status= "${3}"

Local sql= "Delete from T_trans_lock
where dataid= ' ${dataid} ' and datadate= ' ${datadate} '; "
Echo ${sql} | ${db_public}
If [$?-ne 0]; Then
Write_log ${dataid} "free lock failed"
Fi
Return ${status}
}

It is hoped that this article is helpful to everyone's php+mysql program design.


A simple PHP Insert database/Read sample





Untitled Document </title>



if (Isset ($_post[' TJ '))//If you click Submit
{

$conn =mysql_connect ("localhost", "username", "password");
mysql_select_db ("Eastses", $conn);
mysql_query ("Set names UTF8", $conn);
Date_default_timezone_set ("asia/chongqing");
$sql = "INSERT into ' eastses '. ' Classmate ' (' id ', ' name ', ' nickname ', ' Birthday ', ' home ', ' blood ', ' qq ', ' Weibo ', ' email ', ' Phone ', ' hobby ', ' food ', ' sentence ', ' gift ', ' lover ', ' keenon ', ' unforgettable ', ' wanttobecome ', ' ideal ', ' other ') VALUE S (' ". $_post[' id ')." ', ' ". $_post[' name ']." ', ' ". $_post[' nickname ']." ', ' ". $_post[' birthday ']." ', ' ". $_post[' home '." , ' ". $_post[' blood ']." ', ' ". $_post[' QQ '] ... Remaining full text >>

PHP implements a simple registration page and inserts the registration information into the MySQL database

Registration page: reg.html



User name:</td> </td></tr>
Password:</td> </td></tr>
Confirm Password:</td> </td></tr>
Email:</td> </td></tr>
Phone:</td> </td></tr>
</TD></TR>
</table>
</form>

Receive page: reg.php
<%php
$db = mysql_connect ("localhost", "root", "12345");
mysql_select_db ("Dataname", $db);
mysql_query ("INSERT INTO TableName (username, userpass, email, telphone) VALUES (' $_post[username] ', ' $_post[ Userpass] ', ' $_post[email] ', ' $_post[telphone] ');
Echo "registered successfully";
%>
 

http://www.bkjia.com/phpjc/906674. HTML www.bkjia.com true http://www.bkjia.com/phpjc/906674.html techarticle php by inserting MySQL data to implement a multi-machine interlock instance, MySQL example this article describes the PHP through the insertion of MySQL data to achieve multi-machine interlock method, share for everyone for reference. With ...

  • Related Article

    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.