Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 5BFDF47702F for ; Thu, 20 Jun 2002 16:56:05 -0400 (EDT) Received: from mx04.gis.net (mx04.gis.net [208.218.130.12]) by postgresql.org (Postfix) with ESMTP id 0F6B4477394 for ; Thu, 20 Jun 2002 16:15:33 -0400 (EDT) Received: from shell.gis.net ([208.218.129.18]) by mx04.gis.net; Thu, 20 Jun 2002 16:15:33 -0400 Date: Thu, 20 Jun 2002 16:11:15 -0400 (EDT) From: Chadwick Rolfs To: pgsql-php@postgresql.org Subject: Re: Problem involving checkbox and Postgresql In-Reply-To: <1024599680.13975.16.camel@jselfpc> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200206/39 X-Sequence-Number: 1292 I find that an if() statement helps quite a bit. Example: if ($driving_required = 'on') { $driving_required = 1; } else { $driving_required = 0; } Also keep in mind that you can always manipulate ALL of your $_POST or $_GET variables through a foreach() loop and a bunch of if() statements... Hope this helps:) On 20 Jun 2002, Jeff Self wrote: > That only works if I leave the checkboxes checked. If I remove the > check, I get the following error: > > Warning: pg_exec() query failed: ERROR: Bad boolean external > representation '' > in /var/www/nngov/admin/jobpostresults.php on line 66 > > On Thu, 2002-06-20 at 13:39, Surojit Niyogi wrote: > > Hi Jeff, > > > > Set the value parameter in the input tag > > > > > name="driving_required" CHECKED value='1'> > > > > That should work I believe. > > > > -Surojit > > > > Jeff Self wrote: > > > > >I've got a table with a field called driving_required with a boolean > > >type and default 'true'. I've built a web page which contains the > > >following lines for displaying a checkbox: > > > > > >Driver's License Required? > > > > >name="driving_required" CHECKED> > > > > > >After the form is submitted, it calls a php file called > > >jobpostresults.php which enters the data from the form into the database > > >and displays the results on the page. > > > > > >Here's the section that enters the form data into the database: > > > > > >// Add Job Description Details > > >$jddquery = "INSERT INTO job_description_details (description_id, > > >effective_date, driving_required, submitted_on, submitted_by, > > >sm_description, responsibilities, behaviors, skills, experience, > > >requirements) VALUES > > >('$description_id','$effective_date','$driving_required',now(),'$submitted_by','$sm_description','$responsibilities','$behaviors','$skills','$experience','$requirements')"; > > > > > >$jddresult = pg_exec($conn, $jddquery); > > >if (!$jddresult) > > > exit; > > > > > >When I input the data and click on submit I get the following error > > >message: > > > > > >Warning: pg_exec() query failed: ERROR: Bad boolean external > > >representation 'on' > > > in /var/www/nngov/admin/jobpostresults.php on line 46 > > > > > >It looks like the html form is producing 'on' for the value of > > >driving_required. How do I get this changed to 'true' in PostgreSQL? > > > > > > > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 3: if posting/reading through Usenet, please send an appropriate > > subscribe-nomail command to majordomo@postgresql.org so that your > > message can get through to the mailing list cleanly > -- > Jeff Self > Information Technology Analyst > Department of Personnel > City of Newport News > 2400 Washington Avenue > Newport News, VA 23607 > 757-926-6930 > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > -Chadwick