Hello,

I ve got mysql 4.0.1
I don't understand what happen.
I use to make replace other than insert in order to avoid error in php
scripts.

I have a table with on primary key :

CREATE TABLE `nlconfig` (
  `id` tinyint(4) NOT NULL auto_increment,
  `nomnews` varchar(255) NOT NULL default '',
  `hebergeur` varchar(255) NOT NULL default '',
  `fromc` varchar(255) NOT NULL default '[EMAIL PROTECTED]',
  `fromonline` varchar(255) NOT NULL default 'contact',
  `limitconf` tinyint(2) NOT NULL default '7',
  `host` varchar(255) NOT NULL default 'localhost',
  `user` varchar(255) NOT NULL default 'root',
  `passwd` varchar(255) NOT NULL default '',
  `db` varchar(255) NOT NULL default 'newsfr',
  `tablenews` varchar(255) NOT NULL default 'news',
  `tabletemp` varchar(255) NOT NULL default 'temp',
  `tablelog` varchar(255) NOT NULL default 'log',
  `tableconfig` varchar(255) NOT NULL default 'nlconfig',
  `admin_pass` varchar(255) NOT NULL default 'pikatchu',
  `limitlog` tinyint(2) NOT NULL default '10',
  `url` varchar(255) NOT NULL default '',
  `pathtopmn` varchar(255) NOT NULL default 'http://www.test.fr/fr/',
  `langfile` varchar(255) NOT NULL default 'lang-french.php',
  `welcome_subj` varchar(255) NOT NULL default 'bienvenue',
  `welcome_msg` text NOT NULL,
  `sub_msg` text NOT NULL,
  `pied` tinytext NOT NULL,
  `validation` tinyint(1) NOT NULL default '1',
  `description` text,
  `newstemplate` varchar(100) default NULL,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;


When inserting with mysqlfront windows client :

replace into nlconfig values (last_insert_id(),'abc', 'nexen', 'a@', 'a',
'', 'localhost', 'root' , '', 'newsfr', 'news', 'temp', 'log', 'nlconfig',
'lucas', '', '', 'http://www.test.fr/fr/', 'lang-french.php', '','','','',
'1','','' );

1st on row affected
2nd 2rows.

I get no error.
But from a php 4.06 script I get :
errno 1062: erromsg : Duplicata du champ '127' pour la clef 1
That means : duplicate value for key 1.

I didnt have the same result from a php script ?

That the same error i get with NULL in the id with the windows client ?!

Could you explain me what happen ?

I only want to insert a new row when values are different from what is on
the table,
and to replace the row that there is when there is the same id or when all
the data in query is the same !
Is it for that, that replace is for ?


Thanks.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to