On Wed, 2009-08-26 at 22:00 +0800, hack988 hack988 wrote: > my god you use ado connect sorry I'm use php_mysql extentions for all > mssql function. > I'm never use ado connect before. > > 2009/8/26 David Stoltz <Dstoltz@xxxxxxx>: > > 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 > > > > .... > > > > -----Original Message----- > > From: hack988 hack988 [mailto:hack988@xxxxxxxxxxxxx] > > Sent: Wednesday, August 26, 2009 8:08 AM > > To: David Stoltz > > Cc: php-general@xxxxxxxxxxxxx > > Subject: Re: How to output a NULL field? > > > > Could you post your database's class to here? > > I'm use mssql with php for several years and read NULL Fields is never > > appear your case. > > > > 2009/8/26 David Stoltz <Dstoltz@xxxxxxx>: > >> I tried that -it's in the first part of my message > >> > >> > >> -----Original Message----- > >> From: hack988 hack988 [mailto:hack988@xxxxxxxxxxxxx] > >> Sent: Wednesday, August 26, 2009 7:39 AM > >> To: David Stoltz > >> Cc: Paul M Foster; php-general@xxxxxxxxxxxxx > >> Subject: Re: How to output a NULL field? > >> > >> use is_null() check it > >> > >> 2009/8/26 David Stoltz <Dstoltz@xxxxxxx>: > >>> Paul, > >>> > >>> This all started because when I try this: > >>> > >>> <?php echo $rs->Fields(22);?> > >>> > >>> It work fine, as long as there is a non-null value there, otherwise it > >>> produces an error. > >>> > >>> Also, I'm working with a Microsoft SQL 2000 database, not MySQL....not > >>> sure if that matters.... > >>> > >>> But "echo $rs->Fields(22)" works perfectly for dumping values out of my > >>> $rs recordset...that is, unless the value is NULL is the database - then > >>> I get: > >>> > >>> Catchable fatal error: Object of class variant could not be converted to > >>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 176 > >>> > >>> > >>> -----Original Message----- > >>> From: Paul M Foster [mailto:paulf@xxxxxxxxxxxxxxxxx] > >>> Sent: Tuesday, August 25, 2009 4:39 PM > >>> To: php-general@xxxxxxxxxxxxx > >>> Subject: Re: How to output a NULL field? > >>> > >>> On Tue, Aug 25, 2009 at 02:00:04PM -0400, David Stoltz wrote: > >>> > >>>> $rs->Fields(22) equals a NULL in the database > >>>> > >>>> My Code: > >>>> > >>>> if(empty($rs->Fields(22))){ > >>>> $q4 = ""; > >>>> }else{ > >>>> $q4 = $rs->Fields(22); > >>>> } > >>>> > >>>> Produces this error: > >>>> Fatal error: Can't use method return value in write context in > >>>> D:\Inetpub\wwwroot\evaluations\lookup2.php on line 32 > >>>> > >>>> Line 32 is the "if" line... > >>>> > >>>> If I switch the code to (using is_null): > >>>> if(is_null($rs->Fields(22))){ > >>>> $q4 = ""; > >>>> }else{ > >>>> $q4 = $rs->Fields(22); > >>>> } > >>>> > >>>> It produces this error: > >>>> Catchable fatal error: Object of class variant could not be converted > >>> to > >>>> string in D:\Inetpub\wwwroot\evaluations\lookup2.php on line 196 > >>>> > >>>> Line 196 is: <?php echo $q4;?> > >>>> > >>>> What am I doing wrong? > >>>> > >>>> Thanks! > >>> > >>> Just a thought... do you really mean $rs->Fields(22) or do you mean > >>> $rs->Fields[22]? The former is a function call and the latter is an > >>> array variable. > >>> > >>> Paul > >>> > >>> -- > >>> Paul M. Foster > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >> > > > That's impressive, but are you sure you don't use php_mssql extensions instead? :p Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php