RE: NULL Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matijn - it worked! Geez...

Strange - I don't need the ->value if it actually has a value, only if it's NULL...

But it works! Thanks!

-----Original Message-----
From: Matijn Woudt [mailto:tijnema@xxxxxxxxx] 
Sent: Tuesday, April 24, 2012 1:40 PM
To: David Stoltz
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  NULL Problem

On Tue, Apr 24, 2012 at 7:29 PM, David Stoltz <Dstoltz@xxxxxxx> wrote:
> Here's my code (using MSSQL):
>
> $conn = new COM ("ADODB.Connection")or die("Cannot start ADO");
> $conn->open($connStr);
> $query = "SELECT * FROM TABLE WHERE id = ".$id;
> $rs = $conn->execute($query);
>
> This code works fine, and I retrieve the values like this:
>
> $tmp1 = $rs->fields("column1");
> $tmp2 = $rs->fields("column2");
> Etc...
>
>
> Here's the problem - I'm trying to get a date column that I know is
> NULL, but I can't seem to get my code right:
>
> $tmp = $rs->fields("followup_on");
> if(is_null($tmp)){
>        $followup = "";
> }else{
>        $followup = $rs->fields("followup_on");
> }
>
> //this results in: Catchable fatal error: Object of class variant could
> not be converted to string
> //When I try to ECHO the $followup results (and I know the database
> value is NULL)
>
>
> So confused - any advice?
>

It's been a long time ago I worked with ADO (Thank god), but shouldn't
you echo $followup->value instead of $followup?
If that's not working, try a var_dump($followup), so you can check
exactly what it is.

- Matijn



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux