Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  Resolved: error: fields with same name (table&lookup)

phpMyEdit General     Resolved: error: fields with same name (table&lookup)
Post new topic   Reply to topic    
 
mgirard     Joined: 10 Feb 2005   Posts: 2  
Post Posted: 2005-02-10 20:56
Back to top  Reply with quote     

Hello all!!

I just started using phpMyEdit this week and it work Great!!! But now I got a little "bug" that I can't really undertand... perhaps one of you will me able to point me where I misunderstood/maked an error/ else lol.


Code:
There is my error message :

MySQL error 1052

Column: 'start_date' in field list is ambiguous

phpMyEdit error: invalid SQL query

SELECT PMEtable0.id AS qf0,PMEtable0.schedule_id AS qf1,PMEjoin2.contract_number AS qf2,PMEtable0.lease_contract_id AS qf2_idx,concat(substring(start_date, 1, 4), "-", substring(start_date, 5, 2), "-", substring(start_date, 7, 2), " ", substring(start_date, 9, 2), ":", substring(start_date, 11, 2), ":", substring(start_date, 13, 2) ) AS qf3,concat(substring(end_date, 1, 4), "-", substring(end_date, 5, 2), "-", substring(end_date, 7, 2), " ", substring(end_date, 9, 2), ":", substring(end_date, 11, 2), ":", substring(end_date, 13, 2) ) AS qf4 FROM lease_schedules AS PMEtable0 LEFT OUTER JOIN inventory.lease_contracts AS PMEjoin2 ON PMEjoin2.id = PMEtable0.lease_contract_id ORDER BY PMEtable0.schedule_id,PMEtable0.id LIMIT 0,154.897 miliseconds


There is my table and the lookup table creation script :

Code:
CREATE TABLE `lease_schedules` (
  `id` smallint(5) unsigned NOT NULL auto_increment,
  `schedule_id` varchar(20) NOT NULL default '',
  `lease_contract_id` smallint(5) unsigned NOT NULL default '0',
  `start_date` timestamp(14) NOT NULL,
  `end_date` timestamp(14) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `lease_contract_id` (`lease_contract_id`)
) TYPE=MyISAM COMMENT='Lease Schedules'



# Table "lease_contracts" DDL

CREATE TABLE `lease_contracts` (
  `id` smallint(5) unsigned NOT NULL auto_increment,
  `contract_number` varchar(20) NOT NULL default '',
  `financial_ownership_id` smallint(5) unsigned NOT NULL default '0',
  `start_date` timestamp(14) NOT NULL,
  `end_date` timestamp(14) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `financial_ownership_id` (`financial_ownership_id`)
) TYPE=MyISAM COMMENT='Lease Contracts'



And there is what I want to do in my php script. I don't understand I used exactly the same syntax in somes other pages and it work ok...

Code:
$opts['fdd']['id'] = array(
  'name'     => 'ID',
  'select'   => 'T',
  'options'  => '', // auto increment
  'maxlen'   => 5,
  'sort'     => true
);
$opts['fdd']['schedule_id'] = array(
  'name'     => 'Schedule',
  'select'   => 'T',
  'maxlen'   => 20,
  'required' => true,
  'sort'     => true
);

$opts['fdd']['lease_contract_id'] = array(
  'name'     => 'Lease contract',
  'select'   => 'T',
  'maxlen'   => 5,
  'required' => true,
  'sort'     => true
);
$opts['fdd']['lease_contract_id']['values']['table'] = 'lease_contracts';
$opts['fdd']['lease_contract_id']['values']['column'] = 'id';
$opts['fdd']['lease_contract_id']['values']['description'] = 'contract_number';
$opts['fdd']['lease_contract_id']['values2'] = array(''=>'');
$opts['fdd']['lease_contract_id']['sqlw'] = 'if(\'$val\' = \'\',NULL,\'$val\')';

$opts['fdd']['start_date'] = array(
  'name'     => 'Start date',
  'select'   => 'T',
  'maxlen'   => 19,
  'required' => true,
  'sort'     => true,
  'calendar' => true,
   'sql' => 'concat(substring(start_date, 1, 4), "-", substring(start_date, 5, 2), "-", substring(start_date, 7, 2), " ", substring(start_date, 9, 2), ":", substring(start_date, 11, 2), ":", substring(start_date, 13, 2) )'
);


$opts['fdd']['end_date'] = array(
  'name'     => 'End date',
  'select'   => 'T',
  'maxlen'   => 19,
  'required' => true,
  'sort'     => true,
  'calendar' => true,
   'sql' => 'concat(substring(end_date, 1, 4), "-", substring(end_date, 5, 2), "-", substring(end_date, 7, 2), " ", substring(end_date, 9, 2), ":", substring(end_date, 11, 2), ":", substring(end_date, 13, 2) )'
);



Thx for helping me guys!


Last edited by mgirard on 2005-02-10 21:38, edited 3 times in total

 
mgirard     Joined: 10 Feb 2005   Posts: 2  
Post Posted: 2005-02-10 21:03
Back to top  Reply with quote     

SOLUTION :

Code:
$opts['fdd']['start_date'] = array(
  'name'     => 'Start date',
  'select'   => 'T',
  'maxlen'   => 19,
  'required' => true,
  'sort'     => true,
  'calendar' => true,
   'sql' => 'concat(substring(PMEtable0.start_date, 1, 4), "-", substring(PMEtable0.start_date, 5, 2), "-", substring(PMEtable0.start_date, 7, 2), " ", substring(PMEtable0.start_date, 9, 2), ":", substring(PMEtable0.start_date, 11, 2), ":", substring(PMEtable0.start_date, 13, 2) )'
);


 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy