[PHP-DB] [PEAR] help with FormBuilder and checkboxes
marco schrieb: [code] function preGenerateForm() { $this-fb_preDefElements['alive'] = HTML_QuickForm:: createElement('advcheckbox','alive','Ali ve',null,null,$this-alive); } [/code] this code generate a only one checkbox.. i would like to generate a list of checkbox so i tryed [code] function preGenerateForm($fb) {$box=array();$box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '0',null,'0'); $box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '1',null,'1'); $box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '2',null,'2'); $this-fb_preDefElements['checkbox_intention'] = $box; } [/code] but this don't save correctly.. field called checkbox_intention is a varchar(200) and a i would like to save as a list so if i generate []labelA []labelB []labelC []labelDand i check A,C i save in my field valueA,ValueC please help me.. i just send my request of help in forum.. but nobody answer me Hi Marco, I read your code and your description, and I am still not sure I understand what you want to achieve. Please try to rephrase. If your problem is that the elements are not being properly grouped together, try to put the array of elements into a QuickForm group: $group = new HTML_QuickForm_group('checkbox_intention', 'Intention', $box); $this-fb_preDefElements['checkbox_intention'] = $group; See also: http://pear.php.net/manual/en/package.html.html-quickform.php#package.html.html-quickform.groups CU Markus Hallo Marcus, Thanks a lot for your availability, i update my code so : [code] function preGenerateForm() { $box=array(); $box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '0',null,'0'); $box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '1',null,'1'); $box[]= HTML_QuickForm::createElement('advcheckbox','checkbox_intention',null, '2',null,'2'); $group = new HTML_QuickForm_group('checkbox_intention', 'Intention', $box); $this-fb_preDefElements['checkbox_intention'] = $group; } [/code] but it makes an error [error] Notice: Array to string conversion in /usr/share/php5/PEAR/DB/DataObject.php on line 1218 [/error] [input] Intention 0 1 2 [/input] even if i check 0 and 1 and 2 in output [output] Intention [ ]0 [ ]1 [x]2 [/output] Your suggest is near to the correct code version but as you've seen up, there's also some problemes, please help me another one
[PHP-DB] Pear help
Hi There, I'm trying to configure my OS X box to work with PEAR. Everything seems to be working (updating PEAR libraries, etc.) except when I run my test script I get the following error: Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271 Here is my test script: ?php require 'DB.php'; if (class_exists('DB')) { print 'Ok'; } else { print 'Nope'; } ? I've included the path in my PHP.INI file and I still get this error. I've tested this script on another PEAR server and it works fine. Does anyone have any ideas? If this is wrong list, my apologies. Any help would be greatly appreciated. - Craig -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pear help
Craig Hoffman wrote: Hi There, I'm trying to configure my OS X box to work with PEAR. Everything seems to be working (updating PEAR libraries, etc.) except when I run my test script I get the following error: Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271 Here is my test script: ?php require 'DB.php'; if (class_exists('DB')){ print 'Ok'; } else { print 'Nope'; } ? I've included the path in my PHP.INI file and I still get this error. I've tested this script on another PEAR server and it works fine. Does anyone have any ideas? If this is wrong list, my apologies. Any help would be greatly appreciated. Comment out the 'require' line - and run your test script. I expect you'll get the result Ok. If so, you have something somewhere that's already including DB.php. Are you running this test script from within something, or do you actually include some 'common libraries' (your own custom, or some frameworks?). You may also try changing it to require_once, in case something is already require'ing it. The error is clearly stating that there's already a class DB defined. It's defined somewhere. Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pear help
Thanks for getting back to me... Comments below - On Feb 28, 2005, at 10:49 AM, Martin Norland wrote: Craig Hoffman wrote: Hi There, I'm trying to configure my OS X box to work with PEAR. Everything seems to be working (updating PEAR libraries, etc.) except when I run my test script I get the following error: Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271 Here is my test script: ?php require 'DB.php'; if (class_exists('DB')){ print 'Ok'; } else { print 'Nope'; } ? I've included the path in my PHP.INI file and I still get this error. I've tested this script on another PEAR server and it works fine. Does anyone have any ideas? If this is wrong list, my apologies. Any help would be greatly appreciated. Comment out the 'require' line - and run your test script. I expect you'll get the result Ok. If so, you have something somewhere that's already including DB.php. If I comment out the //require it prints my else statement 'Nope' Are you running this test script from within something, or do you actually include some 'common libraries' (your own custom, or some frameworks?). You may also try changing it to require_once, in case something is already require'ing it. I've tried require_once and it just gives me another error: Ok Fatal error: Class 'PEAR_Error' not found in /usr/lib/php/DB.php on line 728 The error is clearly stating that there's already a class DB defined. It's defined somewhere. I'm not sure if this relevant, but I have used db.php (another file) in an include statements to connect mysql for a few websites. Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Pear help
Craig Hoffman wrote: Thanks for getting back to me... Comments below - On Feb 28, 2005, at 10:49 AM, Martin Norland wrote: Craig Hoffman wrote: Hi There, I'm trying to configure my OS X box to work with PEAR. Everything seems to be working (updating PEAR libraries, etc.) except when I run my test script I get the following error: Fatal error: Cannot redeclare class db in /usr/lib/php/DB.php on line 271 [snip] The error is clearly stating that there's already a class DB defined. It's defined somewhere. I'm not sure if this relevant, but I have used db.php (another file) in an include statements to connect mysql for a few websites. Try printing the results of get_declared_classes() and go from there. Maybe class names are case sensitive, I've never had to find out. in any case, as I said - it definitely has already seen a declaration of class db somewhere, the question is finding where that is and whether it's useful or not. One last bit - is DB.php the class you're supposed to use in PEAR, or are you supposed to use something out of the DB directory within PEAR (or is that just the DB specific stuff which is handled by the parent)? I've been working too abstracted a level lately, can't recall :) Cheers, -- - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php