Re: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-27 Thread Alexander Mejenkov
It's not bizarre behaviour
 $result = mysql_query(SELECT * FROM SOME_TABLE) || die (Unable to
execute
 SQL query);
returns result of logical OR operation which is TRUE or 1
without || die(...) it returns valid MySQL resource

Regards
Sasha



Evan Morris [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 If I remove the '|| die' part from the mysql_query() statement, it works
 fine. This is bizarre, but there it is.

 ie, if I have:

 $result = mysql_query(SELECT * FROM SOME_TABLE);

 it works.

 If I have:

 $result = mysql_query(SELECT * FROM SOME_TABLE) || die (Unable to
execute
 SQL query);

 it doesn't work. It gives me:  Supplied argument is not a valid MySQL
 result resource

 Anyway, since it works I don't suppose I should complain, but it seems
 pretty weird to me nevertheless.




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



Re: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-18 Thread Evan Morris
If I remove the '|| die' part from the mysql_query() statement, it works
fine. This is bizarre, but there it is.

ie, if I have:

$result = mysql_query(SELECT * FROM SOME_TABLE);

it works.

If I have:

$result = mysql_query(SELECT * FROM SOME_TABLE) || die (Unable to execute
SQL query);

it doesn't work. It gives me:  Supplied argument is not a valid MySQL
result resource

Anyway, since it works I don't suppose I should complain, but it seems
pretty weird to me nevertheless.


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




Re[2]: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-18 Thread Max 'AMiGo' Gashkov
OK, now I see 8)

$result  after  your operations contains not SQL result, it's value is 1 (logical
TRUE)  -- result of logical operation

mysql_query(SELECT * FROM SOME_TABLE) || die(



If you want to exit after error try this construction:

if(!mysql_query(SELECT * FROM SOME_TABLE))
{
   die(
};

EM If I remove the '|| die' part from the mysql_query() statement, it works
EM fine. This is bizarre, but there it is.

EM ie, if I have:

EM $result = mysql_query(SELECT * FROM SOME_TABLE);

EM it works.

EM If I have:

EM $result = mysql_query(SELECT * FROM SOME_TABLE) || die (Unable to execute
EM SQL query);

EM it doesn't work. It gives me:  Supplied argument is not a valid MySQL
EM result resource

EM Anyway, since it works I don't suppose I should complain, but it seems
EM pretty weird to me nevertheless.



WBR, Max 'AMiGo' Gashkov
[EMAIL PROTECTED] ]=[ http://diary.otaku.ru/amigo
Distributed.net participant [408228][RC5-72]


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




RE: Re[2]: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-18 Thread Clarkson, Nick

I believe if you put OR instead of || it will work OK as originally posted..

ie mysql_query(SELECT * FROM SOME_TABLE) OR die(

Nick

-Original Message-
From: Max 'AMiGo' Gashkov [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2003 08:42
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re[2]: [PHP-DB] More help with mysql -- solved (bizarre)


OK, now I see 8)

$result  after  your operations contains not SQL result, it's value is 1
(logical
TRUE)  -- result of logical operation

mysql_query(SELECT * FROM SOME_TABLE) || die(



If you want to exit after error try this construction:

if(!mysql_query(SELECT * FROM SOME_TABLE))
{
   die(
};

EM If I remove the '|| die' part from the mysql_query() statement, it works
EM fine. This is bizarre, but there it is.

EM ie, if I have:

EM $result = mysql_query(SELECT * FROM SOME_TABLE);

EM it works.

EM If I have:

EM $result = mysql_query(SELECT * FROM SOME_TABLE) || die (Unable to
execute
EM SQL query);

EM it doesn't work. It gives me:  Supplied argument is not a valid MySQL
EM result resource

EM Anyway, since it works I don't suppose I should complain, but it seems
EM pretty weird to me nevertheless.



WBR, Max 'AMiGo' Gashkov
[EMAIL PROTECTED] ]=[ http://diary.otaku.ru/amigo
Distributed.net participant [408228][RC5-72]


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


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


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




RE: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-18 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 18 February 2003 08:26
 
 If I remove the '|| die' part from the mysql_query() 
 statement, it works
 fine. This is bizarre, but there it is.
 
 ie, if I have:
 
 $result = mysql_query(SELECT * FROM SOME_TABLE);
 
 it works.
 
 If I have:
 
 $result = mysql_query(SELECT * FROM SOME_TABLE) || die 
 (Unable to execute
 SQL query);
 
 it doesn't work. It gives me:  Supplied argument is not a valid MySQL
 result resource

The || and OR operators, although both doing a Boolean or, have different priorities, 
so:

  $result = mysql_query(...) or die(...);

is the same as

  ($result = mysql_query(...)) or die(...);

whilst

  $result = mysql_query(...) || die(...);

is the same as

  $result = (mysql_query(...) || die(...));

In the first case, the result of mysql_query() is assigned into $result, and if it 
returns FALSE the die() is performed.  In the second case, the result of applying the 
|| operator to the mysql_query() and the die() is assigned to $result; because PHP 
uses short-circuit evaluation, the die() is still only executed if mysql_query returns 
FALSE, but the || operator still returns a simple Boolean to be assigned to $result -- 
which, if the die() hasn't fired, must be TRUE (which PHP generally prints as 1).  QED.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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