RE: How to output a NULL field?

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

 



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@xxxxxxxxxxxxx] 
Sent: Wednesday, August 26, 2009 12:18 PM
To: Andrew Ballard
Cc: David Stoltz; php-general@xxxxxxxxxxxxx
Subject: Re:  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@xxxxxxxxx>:
> On Wed, Aug 26, 2009 at 9:51 AM, David Stoltz<Dstoltz@xxxxxxx> 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:
>

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



[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