pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
boolean error
6+ messages / 5 participants
[nested] [flat]

* boolean error
@ 2002-05-02 16:31  P. Jourdan <pippo@videotron.ca>
  0 siblings, 4 replies; 6+ messages in thread

From: P. Jourdan @ 2002-05-02 16:31 UTC (permalink / raw)
  To: pgsql-php

I am getting this in the error log file:
ERROR: Bad boolean external representation 
'<font >color=red><b>YES></b></font>'

The code that is generating the message is all within the php delimiters 
(entire file) and appears several times as follows:

if($r1==0 || $r2==0) {
	if($archived=='Y') {
		$archived="<font color=red><b>YES</b></font>";
	}
;;;

select wares.ware_id,wares.name,category.name,unit_size,
	    qty_per_shipping_unit,supplier.name,sku,
	    case when wares.archived='t' then '<font color=red><b>YES</b></font>' 
else wares.archived end as archived,
	    trademark.name
	from wares,category,wares_category,supplier_wares,supplier,trademark
	where wares.ware_id=wares_category.ware_id and
	    category.category_id=wares_category.category_id and
	    wares.ware_id=supplier_wares.ware_id and
	    supplier_wares.supplier_id=supplier.supplier_id and
	    wares.trademark_id=trademark.trademark_id";
I do not understand what is wrong? (This apparently worked fine in the 
original online web site.)
Does anyone understand this?
Philip Jourdan




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: boolean error
@ 2002-05-02 21:20  Surojit Niyogi <surojit@bungeecode.com>
  parent: P. Jourdan <pippo@videotron.ca>
  3 siblings, 0 replies; 6+ messages in thread

From: Surojit Niyogi @ 2002-05-02 21:20 UTC (permalink / raw)
  To: P. Jourdan <pippo@videotron.ca>; +Cc: pgsql-php

It can't understand

<font >color=red><b>YES></b></font>

as a true or false representation for a boolean value.  You need to use 
either (true or false), (yes or no), or (1 or 0)

Roj Niyogi
Founder
pgHoster - PostgreSQL web hosting
http://www.pghoster.com



P. Jourdan wrote:

> I am getting this in the error log file:
> ERROR: Bad boolean external representation '<font 
> >color=red><b>YES></b></font>'
>
> The code that is generating the message is all within the php 
> delimiters (entire file) and appears several times as follows:
>
> if($r1==0 || $r2==0) {
>     if($archived=='Y') {
>         $archived="<font color=red><b>YES</b></font>";
>     }
> ;;;
>
> select wares.ware_id,wares.name,category.name,unit_size,
>         qty_per_shipping_unit,supplier.name,sku,
>         case when wares.archived='t' then '<font 
> color=red><b>YES</b></font>' else wares.archived end as archived,
>         trademark.name
>     from wares,category,wares_category,supplier_wares,supplier,trademark
>     where wares.ware_id=wares_category.ware_id and
>         category.category_id=wares_category.category_id and
>         wares.ware_id=supplier_wares.ware_id and
>         supplier_wares.supplier_id=supplier.supplier_id and
>         wares.trademark_id=trademark.trademark_id";
> I do not understand what is wrong? (This apparently worked fine in the 
> original online web site.)
> Does anyone understand this?
> Philip Jourdan
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
>





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: boolean error
@ 2002-05-02 21:33  Keary Suska <hierophant@pcisys.net>
  parent: P. Jourdan <pippo@videotron.ca>
  3 siblings, 0 replies; 6+ messages in thread

From: Keary Suska @ 2002-05-02 21:33 UTC (permalink / raw)
  To: pgsql-php

on 5/2/02 10:31 AM, pippo@videotron.ca purportedly said:

> I am getting this in the error log file:
> ERROR: Bad boolean external representation
> '<font >color=red><b>YES></b></font>'
> 
> The code that is generating the message is all within the php delimiters
> (entire file) and appears several times as follows:
> 
> if($r1==0 || $r2==0) {
> if($archived=='Y') {
> $archived="<font color=red><b>YES</b></font>";
> }
> ;;;
> 
> select wares.ware_id,wares.name,category.name,unit_size,
> qty_per_shipping_unit,supplier.name,sku,
> case when wares.archived='t' then '<font color=red><b>YES</b></font>'
> else wares.archived end as archived,

All return results of a case statement must be coercible to the same type.
Postgres can't coerce '<font color=red><b>YES</b></font>' into a boolean
value (i.e. wares.archived), hence the error. Since booleans can't be cast
to another type, simply return the expected value:

CASE wares.archived
    WHEN 't' THEN '<font color=red><b>YES</b></font>'
    WHEN 'f' THEN 'f'
ELSE
    NULL
END AS archived


Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: boolean error
@ 2002-05-02 23:16  Chris <csmith@squiz.net>
  parent: P. Jourdan <pippo@videotron.ca>
  3 siblings, 0 replies; 6+ messages in thread

From: Chris @ 2002-05-02 23:16 UTC (permalink / raw)
  To: P. Jourdan <pippo@videotron.ca>; pgsql-php

Hi Philip,

>I am getting this in the error log file:
>ERROR: Bad boolean external representation 
>'<font >color=red><b>YES></b></font>'

As someone else pointed out, in boolean, you can have Y/1 (true) or N/0 
(false); only these values. So when you try to do a boolean check with 
this, it doesn't work because this can't be expressed as 0/1 or Y/N, it's a 
text string.

>The code that is generating the message is all within the php delimiters 
>(entire file) and appears several times as follows:
>
>if($r1==0 || $r2==0) {
>         if($archived=='Y') {
>                 $archived="<font color=red><b>YES</b></font>";
>         }

There are a couple of ways to fix this.

Use a different variable name for displaying the "<font color=red>" - wild 
suggestion - $display_archived - so then the variable $archived isn't 
overwritten when it comes time for it to do your SQL query.

Or, just when you display the output of archived, have a little if statement:
if ($archived == 'y') {
     echo "<font color=red>YES</font>";
} else {
     echo "ARCHIVED IS NO";
}

Hope that helps a bit.


-----------------
      Chris Smith
http://www.squiz.net/




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: boolean error
@ 2002-05-03 12:51  P. Jourdan <pippo@videotron.ca>
  parent: P. Jourdan <pippo@videotron.ca>
  3 siblings, 0 replies; 6+ messages in thread

From: P. Jourdan @ 2002-05-03 12:51 UTC (permalink / raw)
  To: Surojit Niyogi <surojit@bungeecode.com>; +Cc: pgsql-php

At 04:20 PM 5/2/2002 -0500, Roj Niyogi wrote:
>It can't understand
>
><font >color=red><b>YES></b></font>
>
>as a true or false representation for a boolean value.  You need to use 
>either (true or false), (yes or no), or (1 or 0)
Right. Someone else had done the code and I am still trying to figure out 
just what purpose the formatting served as it does not show up on any page. 
I removed the formatting and left the "YES" and now it all works fine.

"Who knows what lies in the hearts of men?... The Shadow does!" :))
Philip Jourdan




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: boolean error
@ 2002-05-03 13:02  Duncan Adams (DNS) <duncan.adams@vcontractor.co.za>
  0 siblings, 0 replies; 6+ messages in thread

From: Duncan Adams (DNS) @ 2002-05-03 13:02 UTC (permalink / raw)
  To: pgsql-php

I think the formatting should be 

<font color=red><b>YES</b></font>

not 

<font >color=red><b>YES></b></font>
      ^                ^

ta 
duncan


-----Original Message-----
From: P. Jourdan [mailto:pippo@videotron.ca]
Sent: Friday, May 03, 2002 2:51 PM
To: Surojit Niyogi
Cc: pgsql-php@postgresql.org
Subject: Re: [PHP] boolean error


At 04:20 PM 5/2/2002 -0500, Roj Niyogi wrote:
>It can't understand
>
><font >color=red><b>YES></b></font>
>
>as a true or false representation for a boolean value.  You need to use 
>either (true or false), (yes or no), or (1 or 0)
Right. Someone else had done the code and I am still trying to figure out 
just what purpose the formatting served as it does not show up on any page. 
I removed the formatting and left the "YES" and now it all works fine.

"Who knows what lies in the hearts of men?... The Shadow does!" :))
Philip Jourdan


---------------------------(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



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-05-03 13:02 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-02 16:31 boolean error P. Jourdan <pippo@videotron.ca>
2002-05-02 21:20 ` Surojit Niyogi <surojit@bungeecode.com>
2002-05-02 21:33 ` Keary Suska <hierophant@pcisys.net>
2002-05-02 23:16 ` Chris <csmith@squiz.net>
2002-05-03 12:51 ` P. Jourdan <pippo@videotron.ca>
2002-05-03 13:02 Re: boolean error Duncan Adams (DNS) <duncan.adams@vcontractor.co.za>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox