Magic has not seen the technology of the great gods to onlookers! MySQL automatically inserts 2 data at a time to solve

Source: Internet
Author: User
Tags what magic
Mysql_connect ("xxx.com", "xxx", "xxx");
mysql_select_db ("XXX");
mysql_query ("Set names ' Utf-8 '");
$ip = "222";
$insql = "INSERT into ' IP ' (' IP ') VALUES (' $ip ')";
mysql_query ($insql);

All pages of PHP code no HTML no form no include ....
But once you plug in 2 strips ...

There would have been the code to get the IP, I completely removed, all the code is above, now magical, one time Insert 2 1 data is the value of the variable IP 222, but also get a local IP address is not obtained in any way!!!!!
Thought it was out of the ghost cache and changed the IP address, and inserted 2, but also a new IP address and 222.

Well, is it a built-in variable $ip can get?? Instead, $IIP also inserts 2 strips,

Okay, SQL statement add ID to $insql= "INSERT into ' IP ' (' ID ', ' IP ') VALUES (' null ', '". $iip. "');";
In a magical result!!!!

I was dreaming??? I met a ghost???



Table structure

CREATE TABLE ' IP ' (
' ID ' int (8) is not NULL,
' IP ' varchar (not NULL)
) Engine=innodb DEFAULT Charset=utf8;

Finally in my attempts to try to only insert a piece of data, not in the insertion of the Magic IP address, the table name changed to Ipip, but still do not understand to ask Gao explained under explanation under. In the absence of any code to obtain the IP: Why can I get the Magic IP address, plug in 2 strips ...

In the second refresh and insert 2, the table name is IPIP, I think it is the Phantom of the SQL statement????
But I have no place to get the IP address in any way. Nor does it use any framework or introduce external files ...

I think someone believes what I'm saying is true? This is really true, ask Kaixie.



I really do not think, afraid of their own hallucinations .... Or in a dream. And then beat yourself a bit. Then in the local do the same thing debugging, the result for the normal insertion of a, solve the above application of what magic caching technology ...... ........... and solve how to insert only one ....


The problem has been found, each 3 times to guess. What causes it, I don't believe anyone can guess!! Ha ha


Reply to discussion (solution)

Does your MySQL have sync capability? and confirm that the my.cnf file

I'll give it a try

Just insert one, I tried.

Post your complete code,

Trigger??

My reckoned is also a trigger problem.

Post your complete code,
This is the complete code!

Brother, this kind of problem, slowly debugging.
1 put the SQL statement in the log to see what it is.
$insql = "INSERT into ' IP ' (' IP ') VALUES (' $ip ')";
2 Adjust the table structure, ID with the self-increment variable, and do the primary key.

To speak more smoothly, we usually use the code in the framework to complete the basic functions of database connection. Find a framework to learn, start with a small one.

Although I do not know the answer, but still support!

I can't think of any other problems other than sloppy.

I can't think of any other problems other than sloppy.
This is not the same as sloppy hanging!

1, will be your page has a duplicate refresh
2. Your mysql_query is not within a loop

You can try this.

In mysql_query ($insql); Add an exit to the back ();
Then go to the database and see

1, will be your page has a duplicate refresh
2. Your mysql_query is not within a loop

You can try this.

In mysql_query ($insql); Add an exit to the back ();
Then go to the database and see
Big Brother if it is repeated refresh or inside the loop? Not getting 2 different data? And one is the IP address without any way?

I can't think of any other problems other than sloppy.
Then you said I was sloppy. Why not sloppy can be solved out!

Seeking the truth. 、

1. Use the tool phpMyAdmin to perform an insert test,
2. Try the current connection to someone else's computer

If both do not produce 2 data, the landlord character has a problem. Need wall

Table name take IP, whether it is MySQL keyword or special character bar,

Hey, no one's on the side!!!

Does it include other. php files that automatically perform an insert method?

Big Brother, you trigger, the equivalent of you execute the two sides of the SQL statement you write, do not believe you change a table, you will suddenly enlightened

I tried it, and I just inserted a record.

Landlord to explain what the reason for the Bai!

' $ip '

What the hell's the problem?

  • 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.