Re: How to output a NULL field?
| From: | Phpster | Date: | Thu, 27 Aug 2009 01:30:49 +0000 |
| Subject: | Re: How to output a NULL field? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-297332@lists.php.net to get a copy of this message | ||
On Aug 26, 2009, at 12:31 PM, "David Stoltz" <Dstoltz@SHH.ORG> wrote:
I'm using COM because I don't know what else to use ;-) Like I said, I'm new to PHP. Here is another way I communicate with the database, let me know if this is a better way (it requires a stored procedure): //Assign the server connection to a variable $connect = mssql_connect(SERVER,1433', USER, 'PASSWORD'); //Select your database and reference the connection mssql_select_db('DATABASE', $connect); // Create a new stored prodecure $stmt = mssql_init('StoredProcedureName'); // Bind the field names mssql_bind($stmt, '@category',$cat,SQLINT4,false,false,4); mssql_bind($stmt, '@userid',$userid,SQLINT4,false,false,4); mssql_bind($stmt, '@passwordtitle',$pname,SQLVARCHAR,false,false,100); mssql_bind($stmt, '@password',$encrypted_data,SQLVARCHAR,false,false,1000); mssql_bind($stmt, '@alt',$alt,SQLVARCHAR,false,false,150); mssql_bind($stmt, '@desc',$desc,SQLVARCHAR,false,false,100); // Execute mssql_execute($stmt); -----Original Message----- From: hack988 hack988 [mailto:hack988@dev.htwap.com] Sent: Wednesday, August 26, 2009 12:18 PM To: Andrew Ballard Cc: David Stoltz; php-general@lists.php.net Subject: Re: [PHP] How to output a NULL field? Com function is just for Windows,I don't kown why some body like use it.:( 2009/8/27 Andrew Ballard <aballard@gmail.com>:MS has developed and released a new version of the mssql drivers for php. It might be worth investigating that to see ifthat firs your needs. Bastien Sent from my iPodOn Wed, Aug 26, 2009 at 9:51 AM, David Stoltz<Dstoltz@shh.org> wrote:-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpSorry - 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: