神奇的没见过的技术大神们来围观啊!mysql一次自动插入2条数据,求解
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);
全部页面的php代码没html没表单没include....
但是一次就插2条一样的。。。
本来有获取IP的代码,我全部去掉了,所有代码就是上面的,现在神奇了,一次插入2条 1条数据为变量ip的值222,还获得一条没有用任何方式获取的本地IP地址!!!!!
以为是出了鬼的缓存又换了IP地址,又插入2条,又是新的IP地址和222。
好吧难道是内置变量$Ip能获取??改为$iip同样插2条,,
好吧sql语句增加ID改成$insql="INSERT INTO `ip` (`id` ,`ip`)VALUES ('null', '".$iip."');";
在一次神奇的结果!!!!
我在做梦???我遇到鬼了???
表结构
CREATE TABLE `ip` (
`id` int(8) NOT NULL,
`ip` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
终于在我百般尝试下只插一条数据了,没有在插入神奇的IP地址了,把表名改成ipip后,但是还是想不明白求高人解释下解释下。。在没有任何代码获取ip的情况下。。 为什么能获取到神奇的IP地址,插2条。。。。。
在次刷新又插入2条,表名是ipip,我想是哪幻存了sql语句????
但是我都没有地方任何方式获取ip地址了啊。。也没有用任何的框架或引入外部文件。。。
我想有人相信我说的是真的吗?这这真的是真的,求开解。。
实在想不通,怕自己产生的幻觉....或者在做梦..然后狠狠的打了自己一下..然后在本地做同样的事情调试了下,结果为正常的插入一条,求解上面的应用的什么神奇的缓存技术...........................和求解怎么只插一条。。。。。。。
问题已经找到了,每人给3次机会猜。什么原因引起的,我不相信能有人能猜到!!哈哈
回复讨论(解决方案)
你的mysql是否有同步功能?并确认my.cnf文件
我试试
只插入一条啊,我试过了。
贴出你完整的代码、
触发器??
我估摸着也是触发器的问题。
贴出你完整的代码、
上面就是完整代码!
兄弟,这种问题,慢慢调试。
1 把sql 语句存日志里看看,究竟是什么.
$insql="INSERT INTO `ip` (`ip`)VALUES ('$ip')";
2 调整一下表结构,id 用自增变量,且做为主键.
顺利多说一下,通常我们都用框架里的代码来完成数据库的连接这类基础功能。 找个框架学学吧,先从小型的开始。
虽然我不知道答案 但还是支持一下!
除了马虎以外,我想不到其他问题。
除了马虎以外,我想不到其他问题。
这跟马虎挂不上边!
1、会不会是你的页面有重复刷新
2、你的mysql_query是不是在一个循环内
你可以这样试下
在 mysql_query($insql); 后面加入一句 exit();
再然再到数据库看下
1、会不会是你的页面有重复刷新
2、你的mysql_query是不是在一个循环内
你可以这样试下
在 mysql_query($insql); 后面加入一句 exit();
再然再到数据库看下
大哥如果是重复刷新或者循环内?不至于得到2条不同的数据?且一条是没有任何途径的IP地址吧?
除了马虎以外,我想不到其他问题。
那你说我哪里马虎了。怎么不马虎能解决掉!
求真相。、
1. 用工具phpmyadmin执行一条insert试试,
2. 用当前的连接别人的计算机试试
如果两条都没有产生2条数据,说明楼主人品有问题。需要面壁
表名取ip,会不会是mysql的关键字或是特殊字符吧,
哎没有人挨到边啊!!!
是不是包含了其他的.php文件自动执行了某个插入方法?
大哥,你触发一下,相当于你执行两边你写的sql语句,不信你换一个表,你就豁然开朗
我试了一下也只是插入一条记录啊~
楼主解释一下到底什么原因呗!
'$ip'
到底什么问题啊

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to write an algorithm to find the least common multiple in Python? The least common multiple is the smallest integer between two numbers that can divide the two numbers. In mathematics, solving the least common multiple is a basic mathematical task, and in computer programming, we can use Python to write an algorithm for solving the least common multiple. The following will introduce the basic least common multiple algorithm and give specific code examples. The mathematical definition of the least common multiple is: If a is divisible by n and b is divisible by n, then n is the least common multiple of a and b. To solve the minimum

How to use Python to implement the algorithm for solving factorial? Factorial is an important concept in mathematics. It means that a number is multiplied by itself minus one, then multiplied by itself minus one, and so on until it is multiplied to 1. Factorial is usually represented by the symbol "!". For example, the factorial of 5 is expressed as 5!, and the calculation formula is: 5!=5×4×3×2×1=120. In Python, we can use loops to implement a simple factorial algorithm. A sample code is given below: deffacto

Numpy is a well-known scientific computing library in Python, which provides rich functions and efficient computing methods for processing large multi-dimensional arrays and matrices. In the world of data science and machine learning, matrix inversion is a common task. In this article, I will introduce how to quickly solve the matrix inverse using the Numpy library and provide specific code examples. First, let's introduce the Numpy library into our Python environment by installing it. Numpy can be installed in the terminal using the following command: pipinsta

Title: Use C language programming to implement the greatest common divisor solution. The greatest common divisor (Greatest Common Divisor, GCD for short) refers to the largest positive integer that can divide two or more integers at the same time. Solving for the greatest common divisor can be very helpful for some algorithms and problem solving. In this article, the function of finding the greatest common divisor will be implemented through C language programming, and specific code examples will be provided. In C language, you can use the Euclidean Algorithm to solve the maximum

To learn how to find the greatest common divisor in C language, you need specific code examples. The greatest common divisor (Greatest Common Divisor, GCD for short) refers to the largest positive integer among two or more integers that can divide them. The greatest common denominator is often used in computer programming, especially when dealing with fractions, simplifying fractions, and solving problems such as the simplest ratio of integers. This article will introduce how to use C language to find the greatest common divisor and give specific code examples. There are many ways to solve the greatest common divisor, such as Euclidean

Here we will see an interesting problem related to modular equations. Let's say we have two values A and B. We must find the number of possible values that variable X can take such that (AmodX)=B holds. Suppose A is 26 and B is 2. So the preferred value of X would be {3,4,6,8,12,24}, hence the count of 6. This is the answer. Let's take a look at the algorithm to understand better. Algorithm possibleWayCount(a,b)−begin ifa=b,thenthereareinfinitesolutions ifa

The Fibonacci sequence is a sequence of numbers in which the next term is the sum of the previous two terms. The first two terms of the Fibonacci sequence are 0 followed by 1. In this problem, we will find the nth number in the Fibonacci sequence. To do this we will count all the numbers and print n items. Input:8Output:011235813 Description 0+1=11+1=21+2=32+3=5 Use a For loop to sum the first two items as the next item Example #include<iostream>usingnamespacestd;intmain(){ intt1= 0,t2=1,n,i,nextTerm;&am

Title: How to solve for powers of 2 in PHP? Specific code examples are shared in PHP programming. Solving the power of numbers is a common requirement, especially in some algorithms and mathematical calculations. This article will discuss in detail how to solve the power of 2 in PHP and provide specific code examples for your reference. In PHP, you can use the exponentiation operator ** to calculate powers. For powers of 2, calculate $2^n$, where $n$ is the exponent of the power. Below we will implement this calculation in a few different ways. Method 1: Use ** luck
