Re: How to output a NULL field?
| From: | Andrew Ballard | Date: | Wed, 26 Aug 2009 16:13:50 +0000 |
| Subject: | Re: How to output a NULL field? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297295@lists.php.net to get a copy of this message | ||
On Wed, Aug 26, 2009 at 9:51 AM, David Stoltz<Dstoltz@shh.org> wrote:
> Sorry - I don't know what you mean by DB class?
>
> I'm using Microsoft SQL 2000....with this code:
>
> <?php
> //create an instance of the ADO connection object
> $conn = new COM ("ADODB.Connection")
> or die("Cannot start ADO");
> //define connection string, specify database driver
> $connStr = "PROVIDER=SQLOLEDB;SERVER=xxxx;UID=xxx;PWD=xxxx;DATABASE=xxxx";
> $conn->open($connStr); //Open the connection to the database
>
> $query = "SELECT * FROM eval_evaluations WHERE id = ".$_POST["eval"];
>
> $rs = $conn->execute($query);
>
> echo $rs->Fields(22); //this is where that particular field is NULL, and produces the error
>
> ....
>
Because you are using COM, you can't use PHP's empty(), isset(), or
is_null() in your if(...) statement. I've not used COM for much in
PHP, but I think you'll have to do something like this:
switch (variant_get_type($rs->Fields(22)) {
case VT_EMPTY:
case VT_NULL:
$q4 = '';
break;
case VT_UI1: