[PHP-DB] RE: PHP4 on Windows using MSSQL

2003-02-26 Thread Kevin Gordon
Thanks Ollie. I will check Tcp or Named Pipes.

I have found a Linux Journal article dated 14 Feb 2003 using a FreeTDS
driver and ODBC to MSSQL and will try that.
Cheers,
Kevin

On Tue, 2003-02-25 at 23:25, Oliver Cronk wrote:
 Yes, but I have never personally used Linux to connect to MSSQL so I can't
 really help you on that one.  Although I hear that several people have done
 this I would really recommend it (as Linux isn't a supported client O/S for
 MSSQL).  It is *fairly* straightforward on Windows - the hardest bit is
 making sure you have all the correct DLL's in the right places etc etc.
 
 I use MySQL/ Postgres these days so I can't really remember all the stuff I
 had to do to get MSSQL working with PHP but I will have a think and let you
 know if I think of anything that might be useful.
 
 After having another quick look at your error message at the bottom of your
 original email it might be worth looking at your MSSQL Server connection
 config dialogs - make sure that TCP/IP has been enabled (looks like you
 might just have named pipes).
 
 Regards
 
 Ollie Cronk
 
 -Original Message-
 From: Kevin Gordon [mailto:[EMAIL PROTECTED]
 Sent: 25 February 2003 08:05
 To: Oliver Cronk
 Cc: PHP Mail
 Subject: RE: PHP4 on Windows  using MSSQL
 
 
 Thanks Ollie
 I guess this means using PHP4 MSSQL functions in Windows and PHP4 Sybase
 functions in Linux?
 
 
 On Tue, 2003-02-25 at 04:47, Oliver Cronk wrote:
  The MSSQL module for PHP DOES NOT USE ODBC.  It uses the C library direct
  style of connecting to MSSQL.  Use your enterprise manager to configure
 the
  appropriate users and permissions and you should be fine.
 
  Ollie Cronk
  www.cronky.net
 
  -Original Message-
  From: Kevin Gordon [mailto:[EMAIL PROTECTED]
  Sent: 24 February 2003 07:09
  To: PHP Mail
  Subject: PHP4 on Windows  using MSSQL
 
 
  Hi Everyone,
 
  From a Linux session:
  ~ # telnet 10.1.1.1 1433
  Trying 10.1.1.1...
  Connected to 10.1.1.1.
  Escape character is '^]'.
  Connection closed by foreign host.
 
  From within NT4 Primary Domain Server:
  SQL Server Query Analyzer using the user login  password applied in PHP
  (and created in MSSQL) Queries processed ok.
 
  In PHP must I use NT authenticated login / password?
 
  Both a PHP client on Linux and Windows receive the same error message:
  Warning: SQL error: [Microsoft][ODBC SQL Server Driver][Named
  Pipes]Specified SQL server not found., SQL state 08001 in SQLConnect in
  E:\Inetpub\wwwroot\php\ODBC_Driver.php on line 174
 
  The PHP.ini file on NT4 has:
  **
  [MSSQL]
  ; Allow or prevent persistent links.
  mssql.allow_persistent = On
 
  ; Maximum number of persistent links.  -1 means no limit.
  mssql.max_persistent = -1
 
  ; Maximum number of links (persistent+non persistent).  -1 means no
  limit.
  mssql.max_links = -1
 
  ; Minimum error severity to display.
  mssql.min_error_severity = 10
 
  ; Minimum message severity to display.
  mssql.min_message_severity = 10
 
  ; Compatability mode with old versions of PHP 3.0.
  mssql.compatability_mode = Off
 
  ; Valid range 0 - 2147483647.  Default = 4096.
  ;mssql.textlimit = 4096
 
  ; Valid range 0 - 2147483647.  Default = 4096.
  ;mssql.textsize = 4096
 
  ; Limits the number of records in each batch.  0 = all records in one
  batch.
  ;mssql.batchsize = 0
 
  ; Use NT authentication when connecting to the server
  mssql.secure_connection = Off
 
  ; Specify max number of processes. Default = 25
  ;mssql.max_procs = 25
 
  
  ntwdblib.dll is in the correct Windows directory.
 
  Using a System DNS for ODBC. Should I be using a File DNS?
 
  Can I open up NT4 PDS to telenet to it?
 
  Any thoughts, comments?
  Many thanks,
 
  Kevin Gordon
  New Zealand
 
 
 
 
 
 
 



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



[PHP-DB] RE: PHP4 on Windows using MSSQL

2003-02-25 Thread Kevin Gordon
Thanks Ollie
I guess this means using PHP4 MSSQL functions in Windows and PHP4 Sybase
functions in Linux?


On Tue, 2003-02-25 at 04:47, Oliver Cronk wrote:
 The MSSQL module for PHP DOES NOT USE ODBC.  It uses the C library direct
 style of connecting to MSSQL.  Use your enterprise manager to configure the
 appropriate users and permissions and you should be fine.
 
 Ollie Cronk
 www.cronky.net
 
 -Original Message-
 From: Kevin Gordon [mailto:[EMAIL PROTECTED]
 Sent: 24 February 2003 07:09
 To: PHP Mail
 Subject: PHP4 on Windows  using MSSQL
 
 
 Hi Everyone,
 
 From a Linux session:
 ~ # telnet 10.1.1.1 1433
 Trying 10.1.1.1...
 Connected to 10.1.1.1.
 Escape character is '^]'.
 Connection closed by foreign host.
 
 From within NT4 Primary Domain Server:
 SQL Server Query Analyzer using the user login  password applied in PHP
 (and created in MSSQL) Queries processed ok.
 
 In PHP must I use NT authenticated login / password?
 
 Both a PHP client on Linux and Windows receive the same error message:
 Warning: SQL error: [Microsoft][ODBC SQL Server Driver][Named
 Pipes]Specified SQL server not found., SQL state 08001 in SQLConnect in
 E:\Inetpub\wwwroot\php\ODBC_Driver.php on line 174
 
 The PHP.ini file on NT4 has:
 **
 [MSSQL]
 ; Allow or prevent persistent links.
 mssql.allow_persistent = On
 
 ; Maximum number of persistent links.  -1 means no limit.
 mssql.max_persistent = -1
 
 ; Maximum number of links (persistent+non persistent).  -1 means no
 limit.
 mssql.max_links = -1
 
 ; Minimum error severity to display.
 mssql.min_error_severity = 10
 
 ; Minimum message severity to display.
 mssql.min_message_severity = 10
 
 ; Compatability mode with old versions of PHP 3.0.
 mssql.compatability_mode = Off
 
 ; Valid range 0 - 2147483647.  Default = 4096.
 ;mssql.textlimit = 4096
 
 ; Valid range 0 - 2147483647.  Default = 4096.
 ;mssql.textsize = 4096
 
 ; Limits the number of records in each batch.  0 = all records in one
 batch.
 ;mssql.batchsize = 0
 
 ; Use NT authentication when connecting to the server
 mssql.secure_connection = Off
 
 ; Specify max number of processes. Default = 25
 ;mssql.max_procs = 25
 
 
 ntwdblib.dll is in the correct Windows directory.
 
 Using a System DNS for ODBC. Should I be using a File DNS?
 
 Can I open up NT4 PDS to telenet to it?
 
 Any thoughts, comments?
 Many thanks,
 
 Kevin Gordon
 New Zealand
 
 
 



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



[PHP-DB] PHP4 on Windows using MSSQL

2003-02-23 Thread Kevin Gordon
Hi Everyone,

From a Linux session:
~ # telnet 10.1.1.1 1433
Trying 10.1.1.1...
Connected to 10.1.1.1.
Escape character is '^]'.
Connection closed by foreign host.

From within NT4 Primary Domain Server:
SQL Server Query Analyzer using the user login  password applied in PHP
(and created in MSSQL) Queries processed ok.

In PHP must I use NT authenticated login / password?

Both a PHP client on Linux and Windows receive the same error message:
Warning: SQL error: [Microsoft][ODBC SQL Server Driver][Named
Pipes]Specified SQL server not found., SQL state 08001 in SQLConnect in
E:\Inetpub\wwwroot\php\ODBC_Driver.php on line 174

The PHP.ini file on NT4 has:
**
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent).  -1 means no
limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

; Minimum message severity to display.
mssql.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0.
mssql.compatability_mode = Off

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textlimit = 4096

; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textsize = 4096

; Limits the number of records in each batch.  0 = all records in one
batch.
;mssql.batchsize = 0

; Use NT authentication when connecting to the server
mssql.secure_connection = Off

; Specify max number of processes. Default = 25
;mssql.max_procs = 25


ntwdblib.dll is in the correct Windows directory.

Using a System DNS for ODBC. Should I be using a File DNS?

Can I open up NT4 PDS to telenet to it?

Any thoughts, comments?
Many thanks,

Kevin Gordon
New Zealand


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



Re: [PHP-DB] PHP4 on Windows using MSSQL

2003-02-21 Thread Kevin Gordon
Hi Coolio
Accessing the Windows NT server from Windows and Linux no longer causes
session errors (which were like: can not find session file, header
already sent and something about cookies).

Trying to access Linux Server (which previously worked 100%). now gives
errors (for example: Fatal error: Call to undefined function:
pg_connect() in E:\Inetpub\wwwroot\php\PgSQL_Driver.php on line 253).
Linux Server has now got the Windows path.

My attention is really trying to resolve: Warning: SQL error:
[Microsoft][ODBC SQL Server Driver][Named Pipes]Specified SQL server not
found., SQL state 08001 in SQLConnect in
E:\Inetpub\wwwroot\php\ODBC_Driver.php on line 174
Error: failed to name the tables.

If someone is using MSSQL database and could comment on PHP.ini, perhaps
that is the area I need to work on.

Cheers for now,
Kevin Gordon
New Zealand

On Fri, 2003-02-21 at 16:23, l coolio wrote:
 Hi Kevin,
 
 Could you tell me what's wrong with the session, maybe I can help, I met 
 really headache problem with session cuz my server is windows, and all my 
 script working with session works fine in non-windows server, I work it out 
 finally, but still not figure out what really went wrong. 
 
 Coolio
 
 
 
 
 
 
 From: Kevin Gordon [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] PHP4 on Windows  using MSSQL
 Date: 20 Feb 2003 20:10:44 +1300
 
 I have written PHP which runs 100% on Linux  Postgresql. I have been
 successful installing PHP4 on windows as an ISAPI MODULE. My PHP code
 runs ok on Windows NT4 ok except:
 (a) Session functions produce errors
 
 (b) I am unable to connect to MSSQL (using ODBC). The System ODBC Driver
 tests ok.
 
 Any Suggestions please?
 
 Kevin Gordon
 
 
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 _
 享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com 
 
 
 



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




[PHP-DB] PHP4 on Windows using MSSQL

2003-02-19 Thread Kevin Gordon
I have written PHP which runs 100% on Linux  Postgresql. I have been
successful installing PHP4 on windows as an ISAPI MODULE. My PHP code
runs ok on Windows NT4 ok except:
(a) Session functions produce errors

(b) I am unable to connect to MSSQL (using ODBC). The System ODBC Driver
tests ok.

Any Suggestions please?

Kevin Gordon



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




RE: [PHP-DB] Calling functions recursively: recursive PHP functions

2003-02-01 Thread Kevin Gordon
Thanks John. Your comment helped me through. I used a static variable
for the array, array_merge_recursive() function to accumulate the
foreign keys and $this-kgforeignkeys as a recursive function in a loop.
This all works ok!

function kgforeignkeys($tablename =  ) 
{
static $totalkgArr;
if ( $this-connection  $tablename !=  ) 
{
$keylist = ;
$sql = SELECT conname,
  pg_catalog.pg_get_constraintdef(oid) as condef 
FROM pg_catalog.pg_constraint r
WHERE r.conrelid = (SELECT c.oid
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace 
n 
ON n.oid = c.relnamespace
WHERE 
pg_catalog.pg_table_is_visible(c.oid)
AND c.relname ~ '^ . 
$tablename . $' )
AND r.contype = 'f';

$keylist = pg_query ($this-connection, $sql);
$num_rows = pg_num_rows($keylist);
for ($i=0; $i  $num_rows; $i++) 
{
$r = pg_fetch_row($keylist);
//  echo Field: $r[0], $r[1] /br;
$phrase = split(\(|\), $r[1]);
//  echo Phrase: $phrase[0], $phrase[1], $phrase[2], 
$phrase[3],
$phrase[4] /br;
$kgArr[$i][0][0] = $tablename;
$word1 = split(,, $phrase[1]);
for ($j=1; $j = count($word1); $j++)
{
$kgArr[$i][0][$j] = trim($word1[$j - 1]);
}
$kgArr[$i][1][0] = trim(Substr($phrase[2], 
strrpos($phrase[2], 
)));
$word2 = split(,, $phrase[3]);
for ($j=1; $j = count($word2); $j++)
{
$kgArr[$i][1][$j] = trim($word2[$j - 1]);
}
}
pg_free_result ($keylist);
$totalkgArr = array_merge_recursive($totalkgArr, $kgArr );
for ($h=0; $h  $num_rows; $h++) 
{
$totalkgArr = $this-kgforeignkeys( $kgArr[$h][1][0] );
}
return $totalkgArr;
}
else 
{
echo 'Failed to obtain the foreign keys in ' . $tablename . 
'br /';
return $totalkgArr;
}
}


On Mon, 2003-01-27 at 19:57, John W. Holmes wrote:
 [snip]
  ?php
  function Test()
  {
  static $count = 0;
  
  $count++;
  echo $count;
  if ($count  10) {
  Test ();
  }
  $count--;
  }
  ?
 
 
 **
  *
  Interesting but I am still lost as I need some help with
  methods/functions within objects:
  In the above example do I need to access Test() by:
  
  if ($count  10) {
  this-Test ();
 
 Yes, without the space: $this-Test();
 
 ---John W. Holmes...
 
 PHP Architect - A monthly magazine for PHP Professionals. Get your copy
 today. http://www.phparch.com/
 
 
 



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




Re: [PHP-DB] Calling functions recursively: recursive PHP functions

2003-01-26 Thread Kevin Gordon
Roberto  Jason thank you for your comments.

Please note the question at the end of this email.

I searched on recursive PHP functions and found: 
[thelist] recursive PHP functions
Rob Wilson thelist at lists.evolt.org
Mon Sep 16 11:00:01 2002

* Previous message: [thelist] recursive PHP functions
* Next message: [thelist] pop up window for image without MSIE image
resize
* Return to the message index sorted by: [ date ] [ thread ] [
subject ] [ author ]

That should read

?php
function recursive ($n)
{
if ($n  10)
{
return $n;
}
echo N = . $n . BR;
$n++;
return recursive ($n);
}
echo The result:.recursive(1).br;
?

With the important line being the :

return recursive ( $n );

This allows you to unwind the recursion correctly.

HTH

Rob
*
Under www.zend.com/manual   chapter 8 Variable scope a mention of
recursion:
 Static variables also provide one way to deal with recursive functions.
A recursive function is one which calls itself. Care must be taken when
writing a recursive function because it is possible to make it recurse
indefinitely. You must make sure you have an adequate way of terminating
the recursion. The following simple function recursively counts to 10,
using the static variable $count to know when to stop:

?php
function Test()
{
static $count = 0;

$count++;
echo $count;
if ($count  10) {
Test ();
}
$count--;
}
?
***
Interesting but I am still lost as I need some help with
methods/functions within objects:
In the above example do I need to access Test() by:

if ($count  10) {
this-Test ();

Comments please.
Kevin Gordon





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




[PHP-DB] Calling functions recursively

2003-01-24 Thread Kevin Gordon
Can functions / methods be called recursively? If so how can this be
done? Comments much appreciated.
Kevin Gordon




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




[PHP-DB] postgresql primarykeys foreignkeys tablenames screenfieldlength

2003-01-20 Thread Kevin Gordon
Any suggestions or improvements to the following code would be much
appreciated. Please send me an email:

function kgtables () 
{
if ($this-connection) 
{
$tablelist = ;
$sql = SELECT  . 
ic.relname  .
FROM  .
pg_class ic  .
WHERE  .
ic.relname not like 'pg%'  .
AND ic.relname not like '%pk'  .
AND ic.relname not like '%idx' ;
$tablelist = pg_query ($this-connection, $sql);
$this-num_tables = pg_num_rows($tablelist);
for ($i=0; $i  $this-num_tables; $i++) 
{
$r = pg_fetch_row($tablelist);
$obj-{$i + 1} = $r[0];
}
pg_free_result ($tablelist);
return $obj;
}
else 
{
echo 'Error: failed to name the tables br /';
return 0;
}
}

function kgprimarykeys ($tablename = ) 
{
if ( $this-connection  $tablename !=  ) 
{
$keylist = ;
$sql = SELECT  . 
ic.relname AS index_name,  .
bc.relname AS tab_name,  . 
ta.attname AS column_name,  .
i.indisunique AS unique_key,  .
i.indisprimary AS primary_key  .
FROM  .
pg_class bc,  .
pg_class ic,  .
pg_index i,  .
pg_attribute ta,  .
pg_attribute ia  .
WHERE  .
bc.oid = i.indrelid  .
AND ic.oid = i.indexrelid  .
AND ia.attrelid = i.indexrelid  .
AND ta.attrelid = bc.oid  .
AND bc.relname = ' . $tablename . ' 
 .
AND ta.attrelid = i.indrelid  .
AND ta.attnum = i.indkey[ia.attnum-1] 
 .
ORDER BY  .
index_name, tab_name, column_name;
$keylist = pg_query ($this-connection, $sql);
$this-num_primarykeys = pg_num_rows($keylist);
$j = 1;
for ($i=0; $i  $this-num_primarykeys; $i++) 
{
$r = pg_fetch_row($keylist);
//  echo Primary Key: $r[0], $r[1], $r[2], $r[3], $r[4], 
/br;
if ( $r[4] == TRUE)
{
$obj-{$j} = $r[2];
$j++;
}
}
pg_free_result ($keylist);
return $obj;
}
else 
{
echo 'Error: failed to name the primary keys in ' . $tablename 
. 'br
/';
return 0;
}
}

function kgforeignkeys ($tablename =  ) 
{
if ( $this-connection  $tablename !=  ) 
{
$keylist = ;
$sql = SELECT conname,
  pg_catalog.pg_get_constraintdef(oid) as condef 
FROM pg_catalog.pg_constraint r
WHERE r.conrelid = (SELECT c.oid
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace 
n 
ON n.oid = c.relnamespace
  

[PHP-DB] SESSION

2002-12-23 Thread Kevin Gordon
After collecting the input data from a FORM via an array (name=kgkeys)
the next function starts:
?php
session_start();
$_SESSION['g_numprimarykeys'] = $_POST['numprimarykeys']; //This always
works ok first time through
$_SESSION['g_kgkeys'] = $_POST['kgkeys']; //This always works ok first
time through
/* An alternative to the above:
if ( $action == edit )
{
$_SESSION['g_numprimarykeys'] = $_POST['numprimarykeys']; // This
always fails - perhaps the block places it out of scope?
$_SESSION['g_kgkeys'] = $_POST['kgkeys']; // This always fails -
perhaps the block places it out of scope?
}
*/
switch ($action)
{
case add:
include ./kgadd.php;
break;
case edit:
include ./kgedit.php;
break;
---
Next file:
?php
session_start();

include(kgstyle.php);
include(Database.php);

$temp = 'g_kgkeys';
foreach ($_SESSION[${temp}] as $key = $val) //This works ok when the
above stores 'g_kgkeys' properly.
{
$pkey[$key] = $val;
}

In php.ini:
register_globals = Off

Question: When including $_SESSION['g_kgkeys'] = $_POST['kgkeys'];
within a block i.e. {}, should it function the same as outside the block
i.e. outside {}?

Your help would be appreciated.

Kevin Gordon




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




[PHP-DB] odbc function return values

2002-08-16 Thread Kevin Gordon

resource *odbc_primarykeys* ( resource connection_id, string qualifier, 
string owner, string table)

resource *odbc_foreignkeys* ( resource connection_id, string 
pk_qualifier, string pk_owner, string pk_table, string fk_qualifier, 
string fk_owner, string fk_table)

int *odbc_tables* ( resource connection_id [, string qualifier [, string 
owner [, string name [, string types)

int *odbc_tableprivileges* ( resource connection_id [, string qualifier 
[, string owner [, string name]]])

The first two functions return resource and the second two functions 
return int. Is there any difference?  

Using a postgresql database odbc_tables works fine. But with 
odbc_primarykeys I can not find a result.

Any advice would be appreciated.

Kevin


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