[PHP-DB] Re: MS SQL error...I've come a long way to get this far

2008-12-08 Thread Fred Silsbee
I was just thinking about something I've never understood completely!

mssql_connect($server, 'sa', 'PW'); presumes the server doesn't have all the 
permissions in spite of the fact that it has the password.

The password I gave is the XP Prof login PW.

Maybe some other PW. 


--- On Mon, 12/8/08, Fred Silsbee [EMAIL PROTECTED] wrote:

 From: Fred Silsbee [EMAIL PROTECTED]
 Subject: MS SQL error...I've come a long way to get this far
 To: php-db@lists.php.net
 Date: Monday, December 8, 2008, 7:13 PM
 many changes to php.ini to get this far..whew!
 
 PHP 5.2.7 just got jerked out from underneathe me (I
 have't replaced it since this is a simple script)
 
 phpinfo works!
 
 ?php
 // Server in the this format:
 computer\instance name or 
 // server,port when using a non default
 port number
 $server = 'LANDON\SQLEXPRESS';
 
 $link = mssql_connect($server, 'sa', 'PW');
line 6
 
 if(!$link)
 {
 die('Something went wrong while connecting to
 MSSQL');
 }
 ?
 
 
 Warning: mssql_connect() [function.mssql-connect]: Unable
 to connect to server: LANDON\SQLEXPRESS in
 C:\Inetpub\wwwroot\trymssql.php on line 6
 Something went wrong while connecting to MSSQL


  


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



RE: [PHP-DB] Re: MS SQL error...I've come a long way to get this far

2008-12-08 Thread Fortuno, Adam
Fred,

If you're using integrated security (e.g., a domain account such as
domain\bob), you won't supply a password. However, the sa account is
a SQL login (v.s. a domain login). In that case, it would make sense
that you supply a password. See the following page for some code to
connect using integrated security:

http://msdn.microsoft.com/en-us/library/cc296205(SQL.90).aspx

See the following page for some code to connect using a SQL login:

http://msdn.microsoft.com/en-us/library/cc296182(SQL.90).aspx

If you're curious if this is even an authentication/permissions issue,
try to login using a domain login. The login event will be recorded in
the `Event Viewer`. If you're attempt isn't recorded, you've got a
communication problem with the server instance. If it is recorded,
you'll be able to tell what the problem is authenticating.

Good luck, and let us know how it turns out.

A-


-Original Message-
From: Fred Silsbee [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 3:30 PM
To: php-db@lists.php.net
Subject: [PHP-DB] Re: MS SQL error...I've come a long way to get this
far

I was just thinking about something I've never understood completely!

mssql_connect($server, 'sa', 'PW'); presumes the server doesn't have all
the permissions in spite of the fact that it has the password.

The password I gave is the XP Prof login PW.

Maybe some other PW. 


--- On Mon, 12/8/08, Fred Silsbee [EMAIL PROTECTED] wrote:

 From: Fred Silsbee [EMAIL PROTECTED]
 Subject: MS SQL error...I've come a long way to get this far
 To: php-db@lists.php.net
 Date: Monday, December 8, 2008, 7:13 PM
 many changes to php.ini to get this far..whew!
 
 PHP 5.2.7 just got jerked out from underneathe me (I
 have't replaced it since this is a simple script)
 
 phpinfo works!
 
 ?php
 // Server in the this format:
 computer\instance name or 
 // server,port when using a non default
 port number
 $server = 'LANDON\SQLEXPRESS';
 
 $link = mssql_connect($server, 'sa', 'PW');
line 6
 
 if(!$link)
 {
 die('Something went wrong while connecting to
 MSSQL');
 }
 ?
 
 
 Warning: mssql_connect() [function.mssql-connect]: Unable
 to connect to server: LANDON\SQLEXPRESS in
 C:\Inetpub\wwwroot\trymssql.php on line 6
 Something went wrong while connecting to MSSQL


  


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


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



Re: [PHP-DB] MySQL Conditional Trigger

2008-12-08 Thread OKi98

 Original Message  
Subject: [PHP-DB] MySQL Conditional Trigger
From: Dee Ayy [EMAIL PROTECTED]
To: php-db@lists.php.net
Date: 31.10.2008 17:09

I don't think my trigger likes a comparison with a variable which is
NULL.  The docs seem to have a few interesting variations on playing
with NULL and I was hoping someone would just throw me a fish so I
don't have to try every permutation (possibly using CASE, IFNULL,
etc.).

If my ShipDate (which is a date datatype which can be NULL) changes to
a non-null value, I want my IF statement to evaluate to TRUE.
IF NULL changes to aDate : TRUE
IF aDate changes to aDifferentDate : TRUE
IF anyDate changes to NULL : FALSE

In my trigger I have:
...
IF OLD.ShipDate != NEW.ShipDate AND NEW.ShipDate IS NOT NULL THEN
...

Which only works when ShipDate was not NULL to begin with.
I suppose it evaluates the following to FALSE
IF NULL != '2008-10-31' AND '2008-10-31' IS NOT NULL THEN
(not liking the NULL != '2008-10-31' part)

Please give me the correct syntax.
TIA

  

anything compared to NULL is always false
NULL = NULL (NULL included) =  false
NULL != anything (NULL included) = false
that's why IS NULL exists

I would go this way:

IF NVL(OLD.ShipDate, -1) != NVL(NEW.ShipDate, -1) THEN




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



RE: [PHP-DB] MySQL Conditional Trigger

2008-12-08 Thread Fortuno, Adam
Dee,

If all you're trying to code is that a value of NULL equates to FALSE
and a date value (whatever date value) equates to true, you can use
something like this:

If ($MyVariable) {
//... true path blah...
} else {
//... false path blah...
}

You can use this because NULL equates to false. If you prefer something
more concise, try the following:

$MyVariable ? //True : //False

I'm not a PHP guy so take this with a grain of salt. If I'm full of it,
don't hesitate to correct me.

A-

-Original Message-
From: OKi98 [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 4:33 PM
To: Dee Ayy
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] MySQL Conditional Trigger

 Original Message  
Subject: [PHP-DB] MySQL Conditional Trigger
From: Dee Ayy [EMAIL PROTECTED]
To: php-db@lists.php.net
Date: 31.10.2008 17:09
 I don't think my trigger likes a comparison with a variable which is
 NULL.  The docs seem to have a few interesting variations on playing
 with NULL and I was hoping someone would just throw me a fish so I
 don't have to try every permutation (possibly using CASE, IFNULL,
 etc.).

 If my ShipDate (which is a date datatype which can be NULL) changes to
 a non-null value, I want my IF statement to evaluate to TRUE.
 IF NULL changes to aDate : TRUE
 IF aDate changes to aDifferentDate : TRUE
 IF anyDate changes to NULL : FALSE

 In my trigger I have:
 ...
 IF OLD.ShipDate != NEW.ShipDate AND NEW.ShipDate IS NOT NULL THEN
 ...

 Which only works when ShipDate was not NULL to begin with.
 I suppose it evaluates the following to FALSE
 IF NULL != '2008-10-31' AND '2008-10-31' IS NOT NULL THEN
 (not liking the NULL != '2008-10-31' part)

 Please give me the correct syntax.
 TIA

   
anything compared to NULL is always false
NULL = NULL (NULL included) =  false
NULL != anything (NULL included) = false
that's why IS NULL exists

I would go this way:

IF NVL(OLD.ShipDate, -1) != NVL(NEW.ShipDate, -1) THEN




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


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



Re: [PHP-DB] MySQL Conditional Trigger

2008-12-08 Thread Chris



anything compared to NULL is always false


Actually it's null.

mysql select false = null;
+--+
| false = null |
+--+
| NULL |
+--+
1 row in set (0.01 sec)

mysql select 1 = null;
+--+
| 1 = null |
+--+
| NULL |
+--+
1 row in set (0.00 sec)

mysql select 2 = null;
+--+
| 2 = null |
+--+
| NULL |
+--+
1 row in set (0.00 sec)


unknown compared to anything is unknown.

--
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP-DB] MySQL Conditional Trigger

2008-12-08 Thread Fortuno, Adam
All,

Chris makes a good point i.e., unknown compared to anything is
unknown. His comment made me want to clarify my earlier note. In my
earlier example, I wasn't suggesting that-that logic be coded in the
database. I was assuming it would be in the page:

?php

$TestNullValue = NULL;

If ($TestNullValue) {
print Evaluates to true!;
} else {
print Evaluates to false!;
}

?

I tested this, and it worked. Here is why, PHP (like pretty much every
other language) silently casts a NULL to false: 

When converting to boolean, the following values are considered FALSE:

 - the boolean FALSE itself 
 - the integer 0 (zero) 
 - the float 0.0 (zero) 
 - the empty string, and the string 0 
 - an array with zero elements 
 - an object with zero member variables (PHP 4 only)
 - the special type NULL (including unset variables) (Booleans,
php.net, 05 Dec. 2008).

If you were going to code it in the database, I'd suggest something like
this:

--Using T-SQL here...
DECLARE @TestNullValue SMALLDATETIME

SET @TestNullValue = NULL

If (@TestNullValue Is Null) 
 PRINT 'Evaluates to true!';
ELSE
 PRINT 'Evaluates to false!';

In either case, this should have the same net result.

Be Well,
A-

-Original Message-
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 5:10 PM
To: OKi98
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] MySQL Conditional Trigger


 anything compared to NULL is always false

Actually it's null.

mysql select false = null;
+--+
| false = null |
+--+
| NULL |
+--+
1 row in set (0.01 sec)

mysql select 1 = null;
+--+
| 1 = null |
+--+
| NULL |
+--+
1 row in set (0.00 sec)

mysql select 2 = null;
+--+
| 2 = null |
+--+
| NULL |
+--+
1 row in set (0.00 sec)


unknown compared to anything is unknown.

-- 
Postgresql  php tutorials
http://www.designmagick.com/


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


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



RE: [PHP-DB] Re: MS SQL error...I've come a long way to get this far

2008-12-08 Thread Fred Silsbee



--- On Mon, 12/8/08, Fortuno, Adam [EMAIL PROTECTED] wrote:

 From: Fortuno, Adam [EMAIL PROTECTED]
 Subject: RE: [PHP-DB] Re: MS SQL error...I've come a long way to get this far
 To: [EMAIL PROTECTED]
 Date: Monday, December 8, 2008, 10:56 PM
 Fred,
 
 Hmm, that makes me think the extension didn't load.
 When you fire up a
 page with ?php php_info(); ? do you see the
 module's information?
 
 If it makes you feel any better, I'm working thru
 integration with
 Oracle, and I'm not fairing too much better.
 
 A-
 
 -Original Message-
 From: Fred Silsbee [mailto:[EMAIL PROTECTED] 
 Sent: Monday, December 08, 2008 5:53 PM
 To: Fortuno, Adam
 Subject: RE: [PHP-DB] Re: MS SQL error...I've come a
 long way to get
 this far
 
 
 
 
 --- On Mon, 12/8/08, Fortuno, Adam
 [EMAIL PROTECTED] wrote:
 
  From: Fortuno, Adam [EMAIL PROTECTED]
  Subject: RE: [PHP-DB] Re: MS SQL error...I've come
 a long way to get
 this far
  To: [EMAIL PROTECTED], php-db@lists.php.net
  Date: Monday, December 8, 2008, 9:26 PM
  Fred,
  
  If you're using integrated security (e.g., a
 domain
  account such as
  domain\bob), you won't supply a
  password. However, the sa account is
  a SQL login (v.s. a domain login). In that case, it
 would
  make sense
  that you supply a password. See the following page for
 some
  code to
  connect using integrated security:
  
 
 http://msdn.microsoft.com/en-us/library/cc296205(SQL.90).aspx
  
  See the following page for some code to connect using
 a SQL
  login:
  
 
 http://msdn.microsoft.com/en-us/library/cc296182(SQL.90).aspx
  
  If you're curious if this is even an
  authentication/permissions issue,
  try to login using a domain login. The login event
 will be
  recorded in
  the `Event Viewer`. If you're attempt isn't
  recorded, you've got a
  communication problem with the server instance. If it
 is
  recorded,
  you'll be able to tell what the problem is
  authenticating.
  
  Good luck, and let us know how it turns out.
  
  A-
  
  
  -Original Message-
  From: Fred Silsbee [mailto:[EMAIL PROTECTED] 
  Sent: Monday, December 08, 2008 3:30 PM
  To: php-db@lists.php.net
  Subject: [PHP-DB] Re: MS SQL error...I've come a
 long
  way to get this
  far
  
  I was just thinking about something I've never
  understood completely!
  
  mssql_connect($server, 'sa', 'PW');
  presumes the server doesn't have all
  the permissions in spite of the fact that it has the
  password.
  
  The password I gave is the XP Prof login PW.
  
  Maybe some other PW. 
  
  
  --- On Mon, 12/8/08, Fred Silsbee
  [EMAIL PROTECTED] wrote:
  
   From: Fred Silsbee [EMAIL PROTECTED]
   Subject: MS SQL error...I've come a long way
 to
  get this far
   To: php-db@lists.php.net
   Date: Monday, December 8, 2008, 7:13 PM
   many changes to php.ini to get this far..whew!
   
   PHP 5.2.7 just got jerked out from underneathe me
 (I
   have't replaced it since this is a simple
 script)
   
   phpinfo works!
   
   ?php
   // Server in the this format:
   computer\instance name or 
   // server,port when using a non
  default
   port number
   $server = 'LANDON\SQLEXPRESS';
   
   $link = mssql_connect($server, 'sa',
  'PW');
  line 6
   
   if(!$link)
   {
   die('Something went wrong while
 connecting to
   MSSQL');
   }
   ?
   
   
   Warning: mssql_connect()
 [function.mssql-connect]:
  Unable
   to connect to server: LANDON\SQLEXPRESS in
   C:\Inetpub\wwwroot\trymssql.php on
 line 6
   Something went wrong while connecting to MSSQL
  
  

  
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 thanks!
 
 using the integrated server login code (first link you
 included, I get:
 
 Fatal error: Call to undefined function sqlsrv_connect() in
 C:\Inetpub\wwwroot\trymssql_1.php on line 7
 
 still banging away


integration with Oracle...Linux or Windows?

I've got the Linux Oracle 11g1/PHP 5.2.6/ and MySQL connection down...I can 
email working code.

When I run :
?php
// Server in the this format: computer\instance name or 
// server,port when using a non default port number
$server = 'LANDON\SQLEXPRESS';

$link = mssql_connect($server, 'sa', 'K^a_t^e_a_u_x_3141');

if(!$link)
{
die('Something went wrong while connecting to MSSQL');
}
?


I get



Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: 
LANDON\SQLEXPRESS in C:\Inetpub\wwwroot\trymssql.php on line 6
Something went wrong while connecting to MSSQL




  


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



Re: [PHP-DB] MySQL Conditional Trigger

2008-12-08 Thread Chris

Fortuno, Adam wrote:

All,

Chris makes a good point i.e., unknown compared to anything is
unknown. His comment made me want to clarify my earlier note. In my
earlier example, I wasn't suggesting that-that logic be coded in the
database. I was assuming it would be in the page:

?php

$TestNullValue = NULL;

If ($TestNullValue) {
print Evaluates to true!;
} else {
print Evaluates to false!;
}

?

I tested this, and it worked. Here is why, PHP (like pretty much every
other language) silently casts a NULL to false: 


When converting to boolean, the following values are considered FALSE:

 - the boolean FALSE itself 
 - the integer 0 (zero) 
 - the float 0.0 (zero) 
 - the empty string, and the string 0 
 - an array with zero elements 
 - an object with zero member variables (PHP 4 only)

 - the special type NULL (including unset variables) (Booleans,
php.net, 05 Dec. 2008).


If you use the shortcut php check, but you can do it the longer way.

if ($value !== null) {
...
}

Can you turn off email notifications too please? It's rather annoying 
when it's on a public mailing list.


--
Postgresql  php tutorials
http://www.designmagick.com/


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