php-windows Digest 8 Apr 2004 18:38:54 -0000 Issue 2200

Topics (messages 23396 through 23397):

Re: How do I access the value of PHP_OS?
        23396 by: Luis Moreira

Re: MS Access, MS SQL Server and UNICDOE text data
        23397 by: Robert Twitty

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- David Scott wrote:

In the PHP on Windows chapter of Programming PHP, there is mention of a constant, PHP_OS, that can be used to determine the OS running the server that PHP is on.

The example code is as follows,

<?php
 if (PHP_OS == "WIN32" || PHP_OS == "WINNT") {
   define("INCLUDE_DIR","c:\\myapps");
 } else {
   // some other platform
   define("INCLUDE_DIR", "/include");
 }
?>

However, rather than checking this value, I'd like to see if flat out. I tried this,

<?php
     echo "PHP_OS";
?>

But it didn't work. How can I see the value contained in this constant?

There is a lot of confusion on your head.
That, and you didn't read the whole thing...
The example MUST include the setting of a variable first, named PHP_OS (or better $PHP_OS), and then proceed to the part you show.


If you write
   echo "PHP_OS";
you are echoing a string, not the contents of a variable.

If you do
if (PHP_OS == "WIN32" || PHP_OS == "WINNT") {
you are doing nothing, since PHP_OS is not a variable. It must be preceded by a dollar sign.




--- End Message ---
--- Begin Message ---
A question pertaining to this topic was posted in another forum. I have
included the answer here for those who have to deal with this issue.

Unlike MS SQL Server 7.0/2000, MS Access 2000 does not use separate types
for non-UNICODE and UNICODE text data. Instead, ALL text data is stored as
UNICODE. In other words, MS Access 2000 no longer has non-UNICODE text
data types. The problem is that the MS Access ODBC driver externally
indcates that they are non-UNICODE. And, the only way to submit queries
containing UNICODE data is with the UNICODE version of the ODBC API.

The only PHP solution that provides access to the UNICODE ODBC API is
ODBTP. To process UNICODE data via PHP/odbtp you must do the following:

1. Include the following HTML meta tag within the HTML head section in
EVERY PHP script and HTML file containing a form that calls a PHP script.

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

2. After connecting to the database with odbtp_connect(), enable UNICODE
SQL support using odbtp_set_attr():

$con = odbtp_connect(...);
odbtp_set_attr( ODB_ATTR_UNICODESQL, TRUE, $con );

3. Rebind all fields bound as ODB_CHAR to ODB_WCHAR after running a query:

$qry = odbtp_query( "SELECT ... FROM ..." );

$cols = odbtp_num_fields( $qry );

for( $col = 0; $col < $cols; $col++ ) {
    if( odbtp_field_bindtype( $qry, $col ) == ODB_CHAR )
        odbtp_bind_field( $qry, $col, ODB_WCHAR );
}

Note: All UNICODE text data is read and sent by the ODBTP server using
UTF-8 encoding and not UCS-2, including query text strings.


Now that I am aware of what MS Access is doing, I will make this a little
easier to do in the next version of ODBTP.


BTW:  Users of MS SQL Server do not have to rebind any fields. The SQL
Server ODBC driver properly indicates which text fields are UNICODE.

-- bob

--- End Message ---

Reply via email to