conditional code causes undefined property error
Posted: Wed Jan 06, 2010 11:35 pm
Hi,
I am trying to add an if statement to my select statement in MYSQL but I keep getting a "Notice: Undefined property: stdClass::$date_sold " error when I try.
Here is the code snippet that works fine:
But when I try to do this
I get the error
I am just trying to display something else on my PHP page if the datetime field is '0000-00-00 00:00:00'
Could anyone help with this?
Thanks in advance
I am trying to add an if statement to my select statement in MYSQL but I keep getting a "Notice: Undefined property: stdClass::$date_sold " error when I try.
Here is the code snippet that works fine:
Code: Select all
$sql = "
SELECT
i.id,
i.name,
i.featured_item,
i.sales_status,
c.name room_type,
im.name image,
i.date_added,
i.date_last_modified,
i.date_sold
FROM
inventory i
etc.....
Code: Select all
$sql = "
SELECT
i.id,
i.name,
i.featured_item,
i.sales_status,
c.name room_type,
im.name image,
i.date_added,
i.date_last_modified,
CASE i.date_sold
WHEN '0000-00-00 00:00:00' THEN 'Not Sold'
END
FROM
inventory i
I am just trying to display something else on my PHP page if the datetime field is '0000-00-00 00:00:00'
Could anyone help with this?
Thanks in advance