Thread: booleans
Good day all, I just wrote an HTML form with a PHP script to enter data into a table witha boolean field. When I pressed enter it returned the following error "Warning: PostgresSQL query failed: ERROR: Bad boolean external representation". The script is as follows: if( $id ) { pg_Exec($conn, "INSERT into authors VALUES ('$pubrelease', '$id', '$first');"); } I would appreciate any help. Thanks, -Greg
Gregory Holston wrote: > > Good day all, > > I just wrote an HTML form with a PHP script to enter data into a table > witha boolean field. When I pressed enter it returned the following error > "Warning: PostgresSQL query failed: ERROR: Bad boolean external > representation". The script is as follows: > > if( $id ) { > pg_Exec($conn, "INSERT into authors > VALUES ('$pubrelease', '$id', '$first');"); > } > > I would appreciate any help. > Postgres supports bool as the SQL3 boolean type. bool can have one of only two states: 'true' or 'false'. Boolean accepts only one of the following values: True: 't', TRUE, 't', 'true', 'y', 'yes', '1' False: 'f', FALSE, 'f', 'false', 'n', 'no', '0' - Note that you have to enclose data between '' except for words TRUE/FALSE. Probably you are trying to insert data in a different way. -Jose'-
Initially I was inputing 't' and 'f'. Then I tried 1 and 0 and it worked. PHP3 cannot parse t or f I guess. Thanks for the info, -Greg
On Tue, 29 Dec 1998, Gregory Holston wrote: > Date: Tue, 29 Dec 1998 12:36:32 -0500 (EST) > From: Gregory Holston <holston@itd.nrl.navy.mil> > To: Jose' Soares <jose@sferacarta.com> > Cc: pgsql-sql@hub.org > Subject: Re: [SQL] booleans > > > Initially I was inputing 't' and 'f'. Then I tried 1 and 0 and it > worked. PHP3 cannot parse t or f I guess. Did you echo your query on the page on which you execute it to see exactly what it looks like when you're trying it with 't' and 'f'?? I'd bet you're having some problem related to the escaping of quotes. What is your magic_quotes_gpc setting? PHP shouldn't have any problems delivering this query to Postgres... > > Thanks for the info, > > -Greg > > _______________________ Eric McKeown ericm@palaver.net http://www.palaver.net
I wouldn't think it would have any problem handling this code either, code I used was : if( $id ) { pg_Exec($conn, "INSERT into authors values ('$pubrelease', '$id', '$first');"); } First was the variable where the boolean, t or f was to be placed in the HTML form. I did not put quotes insert them with quotes for this is already done with the PHP. This works for int, text, etc. hich was why I was surprised by the error message. -Greg