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

2003-02-18 Thread Max 'AMiGo' Gashkov
Possible error in SQL statement.
Are you sure that SOME_TABLE exists?

EM Hi all

EM I have successfully managed to connect to the mysql database, using the
EM following code:

EM mysql_connect('localhost','php','***') || die (Unable to connect to
EM MySQL server.);
EM $db = mysql_select_db(DB_NAME) || die (Unable to select requested
EM database.);

EM I then issue the following command:

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

EM This does not result in any error.

EM Now, of course, I want to work with the data returned, so I go:

EM if (mysql_num_rows($result)  0)
EM {
EM // do some stuff
EM }
EM else
EM {
EM // do some other stuff
EM };

EM However, this gives me: Supplied argument is not a valid MySQL result
EM resource.

EM If I go: echo $result, I get '1', so I know $result actually has some
EM value.

EM What am I doing wrong? Basically, I want to do the simplest thing: get data
EM out of a table and step through the results, displaying them one by one. Why
EM is this hard?

EM Evan Morris
EM [EMAIL PROTECTED]
EM Tel: +27 11 792 2777
EM Fax: +27 11 792 2711
EM Cell: +27 82 926 3630

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: [PHP-DB] More help with mysql

2003-02-18 Thread Corne' Cornelius
Yo Evan,

Have you got an '@' in front of the mysql_query() to supress errors ?



Evan Morris wrote:


Hi all

I have successfully managed to connect to the mysql database, using the
following code:

mysql_connect('localhost','php','***') || die (Unable to connect to
MySQL server.);
$db = mysql_select_db(DB_NAME) || die (Unable to select requested
database.);

I then issue the following command:

$result = mysql_query(SELECT * FROM SOME_TABLE) || die(mysql_error());

This does not result in any error.

Now, of course, I want to work with the data returned, so I go:

if (mysql_num_rows($result)  0)
   {
   // do some stuff
   }
else
   {
   // do some other stuff
   };

However, this gives me: Supplied argument is not a valid MySQL result
resource.

If I go: echo $result, I get '1', so I know $result actually has some
value.

What am I doing wrong? Basically, I want to do the simplest thing: get data
out of a table and step through the results, displaying them one by one. Why
is this hard?

Evan Morris
[EMAIL PROTECTED]
Tel: +27 11 792 2777
Fax: +27 11 792 2711
Cell: +27 82 926 3630



 





=Disclaimer and Confidentiality===
This message contains information intended for the perusal, and/or use (if so stated), by the stated addressee(s) only. The information is confidential and privileged. If you are not an intended recipient, do not peruse, use, disseminate, distribute, copy or in any manner rely upon  he information contained in this message (directly or indirectly). The sender and/or the entity represented by the sender shall not be held accountable in the event that this prohibition is disregarded. If you receive this message in error, notify the sender immediately by e-mail, fax or telephone representations contained in this message, whether express or implied, are those of the sender only, unless that sender expressly states them to be the views or representations of an entity or person, who shall be named by the sender and who the sender shall state to represent. No liability shall otherwise attach to any other entity or person. ==


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




Re: [PHP-DB] More help with mysql

2003-02-18 Thread Evan Morris
- Original Message -
From: Max 'AMiGo' Gashkov [EMAIL PROTECTED]
To: Evan Morris [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, February 18, 2003 10:13 AM
Subject: Re: [PHP-DB] More help with mysql


 Possible error in SQL statement.
 Are you sure that SOME_TABLE exists?

Yes. I can connect to it from Perl, using the same user-pass credentials,
and fetch our all the data without any problems.


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




Re: [PHP-DB] More help with mysql

2003-02-18 Thread Evan Morris
Since I'm new to PHP, this concept is new to me. What does the @ do and
where do you put it?

- Original Message -
From: Corne' Cornelius [EMAIL PROTECTED]
To: Evan Morris [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, February 18, 2003 10:19 AM
Subject: Re: [PHP-DB] More help with mysql


 Yo Evan,

 Have you got an '@' in front of the mysql_query() to supress errors ?




-- 
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

2003-02-18 Thread Max 'AMiGo' Gashkov
Try listing of fields by name, not as '*', and put SOME_TABLE in qoutes (').

EM - Original Message -
EM From: Max 'AMiGo' Gashkov [EMAIL PROTECTED]
EM To: Evan Morris [EMAIL PROTECTED]
EM Cc: [EMAIL PROTECTED]
EM Sent: Tuesday, February 18, 2003 10:13 AM
EM Subject: Re: [PHP-DB] More help with mysql


 Possible error in SQL statement.
 Are you sure that SOME_TABLE exists?

EM Yes. I can connect to it from Perl, using the same user-pass credentials,
EM and fetch our all the data without any problems.






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: [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




[PHP-DB] More help with mysql

2003-02-17 Thread Evan Morris
Hi all

I have successfully managed to connect to the mysql database, using the
following code:

mysql_connect('localhost','php','***') || die (Unable to connect to
MySQL server.);
$db = mysql_select_db(DB_NAME) || die (Unable to select requested
database.);

I then issue the following command:

$result = mysql_query(SELECT * FROM SOME_TABLE) || die(mysql_error());

This does not result in any error.

Now, of course, I want to work with the data returned, so I go:

if (mysql_num_rows($result)  0)
{
// do some stuff
}
else
{
// do some other stuff
};

However, this gives me: Supplied argument is not a valid MySQL result
resource.

If I go: echo $result, I get '1', so I know $result actually has some
value.

What am I doing wrong? Basically, I want to do the simplest thing: get data
out of a table and step through the results, displaying them one by one. Why
is this hard?

Evan Morris
[EMAIL PROTECTED]
Tel: +27 11 792 2777
Fax: +27 11 792 2711
Cell: +27 82 926 3630



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