Обсуждение: boolean error

Поиск
Список
Период
Сортировка

boolean error

От
"P. Jourdan"
Дата:
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


Re: boolean error

От
Surojit Niyogi
Дата:
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
>
>



Re: boolean error

От
Keary Suska
Дата:
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"


Re: boolean error

От
Chris
Дата:
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/


Re: boolean error

От
"P. Jourdan"
Дата:
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


Re: boolean error

От
"Duncan Adams (DNS)"
Дата:
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