|
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
Hello,
I use php/mysql for several years, and there, an error without explanation. The PHP script below inserts an record two times, the same two times. Why ? Any idea ? Thank you Francois include ('connecte.csv'); $link = mysql_connect($sql,$user,$pwd) or die("ERROR"); mysql_select_db($db,$link); mysql_query("insert into listescouts (categorie,nom) values ('test','essai')",$link); mysql_close($link); With another table, no problem. Both tables were built in the same time (different fields of course) |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
Almaleh wrote:
> Hello, > > I use php/mysql for several years, and there, an error without explanation. > > The PHP script below inserts an record two times, the same two times. > Why ? Any idea ? > > Thank you > Francois > > > include ('connecte.csv'); > $link = mysql_connect($sql,$user,$pwd) or die("ERROR"); > mysql_select_db($db,$link); > mysql_query("insert into listescouts (categorie,nom) values > ('test','essai')",$link); > mysql_close($link); > > With another table, no problem. Both tables were built in the same time > (different fields of course) > > It won't, unless you're calling the script twice. Echo a message every time you execute it and see what you get. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
> It won't, unless you're calling the script twice.
Only one time, I'm sure. > Echo a message every time you execute it and see what you get. Nothing, the script is simple and without problem in its syntax "Insert into"... inserted in phpmyadmin is ok : only one record inserted, but with the previous php script, it's bad (although with another table, it's ok) Francois |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
Almaleh wrote:
> I use php/mysql for several years, and there, an error without explanation. > The PHP script below inserts an record two times, the same two times. > Why ? Any idea ? > include ('connecte.csv'); > $link = mysql_connect($sql,$user,$pwd) or die("ERROR"); > mysql_select_db($db,$link); > mysql_query("insert into listescouts (categorie,nom) values > ('test','essai')",$link); > mysql_close($link); The script most likely is called twice. -- //Aho |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
Almaleh wrote:
>> It won't, unless you're calling the script twice. > Only one time, I'm sure. > >> Echo a message every time you execute it and see what you get. > Nothing, the script is simple and without problem in its syntax > > "Insert into"... inserted in phpmyadmin is ok : only one record > inserted, but with the previous php script, it's bad (although with > another table, it's ok) > > Francois > > The code you posted will only insert twice if you call it twice. Try putting the following in your code: echo "I'm inserting a new record now<br>\n"; And see if you don't get two messages. Either that or you're inserting in another place, also. Comment out the mysql_query statement and see if it's getting inserted at all. One or the other is happening. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
> The PHP script below inserts an record two times, the same two times.
> Why ? Any idea ? > mysql_query("insert into listescouts (categorie,nom) values > ('test','essai')",$link); add timestamp to your query, you will be able to compare time of inserted values. if script is called two times it will be visible as two diffirent timestamps. regards, R. |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
Après mûre réflexion, J.O. Aho a écrit :
> Almaleh wrote: >> I use php/mysql for several years, and there, an error without explanation. >> The PHP script below inserts an record two times, the same two times. >> Why ? Any idea ? >> include ('connecte.csv'); >> $link = mysql_connect($sql,$user,$pwd) or die("ERROR"); >> mysql_select_db($db,$link); >> mysql_query("insert into listescouts (categorie,nom) values >> ('test','essai')",$link); >> mysql_close($link); > > > The script most likely is called twice. I don't think so because there is only a mysql_query instruction. What do you think , Thanks Francois |
|
|
|
#8 (permalink) |
|
Messages: n/a
Hébergeur: |
aaooo54 a émis l'idée suivante :
>> The PHP script below inserts an record two times, the same two times. >> Why ? Any idea ? >> mysql_query("insert into listescouts (categorie,nom) values >> ('test','essai')",$link); > > add timestamp to your query, you will be able to compare time of inserted > values. > if script is called two times it will be visible as two diffirent timestamps. > regards, > R. thanks but the result is not very significant because it's measured in second not in milliseconds Francois |
|
![]() |
| Outils de la discussion | |
|
|