On Wed, Aug 26, 2009 at 12:13 PM, Andrew Ballard<aball...@gmail.com> wrote:
> On Wed, Aug 26, 2009 at 9:51 AM, David Stoltz<dsto...@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:
>

blast ... hit some key and Gmail just sent what I had typed so far.

At any rate, hopefully you can get the idea from that last post. Look
at this reference for handling different types returned from COM:

http://www.php.net/manual/en/com.constants.php


I would also suggest looking into a PHP library for querying SQL
Server rather than relying on COM. There are several, some work better
than others. I've found that the SQL Server Driver for PHP works best
for what I use. It is documented as being for 2005 and newer, but I
have been able to use it just fine with 2000 as well.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to