Re: [PHP] mysql if empty

2007-04-11 Thread Jim Lucas

tedd wrote:

At 5:53 PM -0700 4/10/07, Jim Lucas wrote:

Anyways, here is the expanded version hopefully to your liking.


# Your request failed.  Make up your own custom way of displaying 
the error.

} else {
if ( mysql_num_rows($results) > 0 ) {
while ( $row = mysql_fetch_assoc($result) ) {
if ( isset($row['client']) && !empty($row['client']) ) {
echo $row['client'] . '';
}
}
} else {
echo 'No results found!';
}
}
?>

Does this satisfy you?


Actually, it's $result and not $results. Other than that, it works fine 
as far as I can tell.


Cheers,

tedd

good catch, missed that.

Thanks

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



Re: [PHP] mysql if empty

2007-04-11 Thread tedd

At 5:53 PM -0700 4/10/07, Jim Lucas wrote:

Anyways, here is the expanded version hopefully to your liking.


	# Your request failed.  Make up your own custom way of 
displaying the error.

} else {
if ( mysql_num_rows($results) > 0 ) {
while ( $row = mysql_fetch_assoc($result) ) {
			if ( isset($row['client']) && 
!empty($row['client']) ) {

echo $row['client'] . '';
}
}
} else {
echo 'No results found!';
}
}
?>

Does this satisfy you?


Actually, it's $result and not $results. Other than that, it works 
fine as far as I can tell.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] mysql if empty

2007-04-10 Thread tg-php
Top-posting is sublime.  Embrace it.  Why scroll through 10 pages of emails 
you've already read when you can get to the meat of it all in the first few 
lines of an email?  :)

Plus trying to quickly separate all the previous replies from the latest one 
when some emailers indent, indent with leading character (ie. "> "), use 
horizontal dividers, etc.  No standardization there.  Top posting lets you read 
until you find the first divider, not the last.. hah

The problem is the lack of agreement on this perfectly logical assessment.  
Mixing top and bottom posting gets ugly, I agree on that.  But since I don't 
need to re-read what's already been said in a conversation that's fresh in my 
mind, I don't have to see all the mix of top/bottom and non-standardized reply 
dividers.

Top-posting is the only logical choice.


(why do I always have to rattle the hornet's nest?  god.. this used to be a 
nice list before I started messing it all up with OT subjects)

-TG


= = = Original message = = =

No.

Despite the fact that I replied to your message as it was the "last"
one, and that caused threaded mail readers to place my post directly
under yours as a "reply", my comment was not specifically directed at
your post.

I had deleted the "way wrong" posts by the time I realized I wanted to
say something about them...

Apologies that my email/reading/posting habits are only somewhat
conformant with threaded readers...

Damn!  And I just top-posted too! :-v

On Tue, April 10, 2007 7:53 pm, Jim Lucas wrote:
> Richard Lynch wrote:
>> I am amazed by the sheer number of just plain WRONG answers to this
>> one...
>>
>> Were they all from April 1 or something?...
>>
> so, are you saying that my answer was wrong, or just making a
> statement.
>
> If my answer was wrong, it was because it was too simple, which is
> what I was trying to get at, so
> as not to confuse the OP.
>
> Anyways, here is the expanded version hopefully to your liking.
>
>
> 
> // do that db connection thing...
> // select you database
>
> $sql = "SELECT
> ~~Client
> ~FROM
> ~~booked
> ~WHERE
> ~~Name = 'larry'
> ";
>
> if ( ( $result = mysql_query($sql) ) === false ) 
> ~# Your request failed.  Make up your own custom way of displaying the
> error.
>  else 
> ~if ( mysql_num_rows($results) > 0 ) 
> ~~while ( $row = mysql_fetch_assoc($result) ) 
> ~~~if ( isset($row['client']) && !empty($row['client']) ) 
> echo $row['client'] . '';
> ~~~
> ~~
> ~ else 
> ~~echo 'No results found!';
> ~
> 
> ?>
>
> Does this satisfy you?
>
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] mysql if empty

2007-04-10 Thread Robert Cummings
On Tue, 2007-04-10 at 20:48 -0500, Richard Lynch wrote:
> No.
> 
> Despite the fact that I replied to your message as it was the "last"
> one, and that caused threaded mail readers to place my post directly
> under yours as a "reply", my comment was not specifically directed at
> your post.
> 
> I had deleted the "way wrong" posts by the time I realized I wanted to
> say something about them...
> 
> Apologies that my email/reading/posting habits are only somewhat
> conformant with threaded readers...
> 
> Damn!  And I just top-posted too! :-v

No worries, I don't think there's any top-post police left on the
list :B

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] mysql if empty

2007-04-10 Thread Richard Lynch
No.

Despite the fact that I replied to your message as it was the "last"
one, and that caused threaded mail readers to place my post directly
under yours as a "reply", my comment was not specifically directed at
your post.

I had deleted the "way wrong" posts by the time I realized I wanted to
say something about them...

Apologies that my email/reading/posting habits are only somewhat
conformant with threaded readers...

Damn!  And I just top-posted too! :-v

On Tue, April 10, 2007 7:53 pm, Jim Lucas wrote:
> Richard Lynch wrote:
>> I am amazed by the sheer number of just plain WRONG answers to this
>> one...
>>
>> Were they all from April 1 or something?...
>>
> so, are you saying that my answer was wrong, or just making a
> statement.
>
> If my answer was wrong, it was because it was too simple, which is
> what I was trying to get at, so
> as not to confuse the OP.
>
> Anyways, here is the expanded version hopefully to your liking.
>
>
> 
> // do that db connection thing...
> // select you database
>
> $sql = "SELECT
>   Client
>   FROM
>   booked
>   WHERE
>   Name = 'larry'
> ";
>
> if ( ( $result = mysql_query($sql) ) === false ) {
>   # Your request failed.  Make up your own custom way of displaying the
> error.
> } else {
>   if ( mysql_num_rows($results) > 0 ) {
>   while ( $row = mysql_fetch_assoc($result) ) {
>   if ( isset($row['client']) && !empty($row['client']) ) {
>   echo $row['client'] . '';
>   }
>   }
>   } else {
>   echo 'No results found!';
>   }
> }
> ?>
>
> Does this satisfy you?
>
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] mysql if empty

2007-04-10 Thread Jim Lucas

[EMAIL PROTECTED] wrote:

Turn on MAGIC QUOTES and REGISTER GLOBALS

Once you've done that, install Postgres.  Run your MySQL command again, 
Postgres has much better error reporting and will assist in debugging the 
situation.

You might consider replacing your javascript functions with PHP ones since JS can sometimes 
interfere with MySQL result sets and PHP provide superior client side scripting anyway.  

Re: [PHP] mysql if empty

2007-04-10 Thread Jim Lucas

Richard Lynch wrote:

I am amazed by the sheer number of just plain WRONG answers to this
one...

Were they all from April 1 or something?...


so, are you saying that my answer was wrong, or just making a statement.

If my answer was wrong, it was because it was too simple, which is what I was trying to get at, so 
as not to confuse the OP.


Anyways, here is the expanded version hopefully to your liking.


 0 ) {
while ( $row = mysql_fetch_assoc($result) ) {
if ( isset($row['client']) && !empty($row['client']) ) {
echo $row['client'] . '';
}
}
} else {
echo 'No results found!';
}
}
?>

Does this satisfy you?

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



Re: [PHP] mysql if empty

2007-04-10 Thread tg-php
Turn on MAGIC QUOTES and REGISTER GLOBALS

Once you've done that, install Postgres.  Run your MySQL command again, 
Postgres has much better error reporting and will assist in debugging the 
situation.

You might consider replacing your javascript functions with PHP ones since JS 
can sometimes interfere with MySQL result sets and PHP provide superior client 
side scripting anyway.  

Re: [PHP] mysql if empty

2007-04-10 Thread Lori Lay

Richard Lynch wrote:

I am amazed by the sheer number of just plain WRONG answers to this
one...

Were they all from April 1 or something?...
  


Yes it's unfortunate.  I think part of the problem was that several 
people, including myself, weren't entirely clear on what he was after.  
When I re-read his note later, I realized that the num. rows test was 
the correct answer.


When you're posting to the list, you have to remember that we're not 
sitting beside you!  Try to tell us what you hope to accomplish with 
your script and you might get better replies...


Lori

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



Re: [PHP] mysql if empty

2007-04-10 Thread Richard Lynch
I am amazed by the sheer number of just plain WRONG answers to this
one...

Were they all from April 1 or something?...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] mysql if empty

2007-04-10 Thread Richard Lynch
$result == "" means:
Your SQL query is so f'ed up, I couldn't even run it.

It does NOT mean:
Your query returned zero rows, a perfectly normal and common condition.

You want http://php.net/mysql_num_rows

And, actually, $result is FALSE, not really "", when the query is wrong.

On Mon, April 9, 2007 4:18 pm, [EMAIL PROTECTED] wrote:
> If I search for something in mysql that returns an empty result I cant
> get
> it to return
> "No result found" always returns "Found" even though the recoed does
> not
> exist...
>
>
> $sql = "SELECT Client FROM booked WHERE Name = 'larry'";
>
> $result = mysql_query($sql);
>
> if ($result == "")
> {
> echo "No result found";
> }
> echo "Found";
>
>
> - Original Message -
> From: "Martin Marques" 
> To: "Stut" <[EMAIL PROTECTED]>
> Cc: "Tijnema !" <[EMAIL PROTECTED]>; "tedd" <[EMAIL PROTECTED]>;
> "Peter
> Lauri" <[EMAIL PROTECTED]>; "Ólafur Waage" <[EMAIL PROTECTED]>;
> 
> Sent: Monday, April 09, 2007 9:45 PM
> Subject: Re: [PHP] Session Authentication
>
>
>> Stut escribió:
>>> As with most things these days it probably breaches the DMCA. But
>>> frankly
>>> speaking, if doing that works then the developers of the
>>> application, and
>>> by extension the company, deserve everything they get.
>>
>> DMCA is a real piece of crap.
>>
>> --
>> select 'mmarques' || '@' || 'unl.edu.ar' AS email;
>> -
>> Martín Marqués  |   Programador, DBA
>> Centro de Telemática | Administrador
>>Universidad Nacional
>> del Litoral
>> -
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] mysql if empty

2007-04-10 Thread Jim Lucas

[EMAIL PROTECTED] wrote:
If I search for something in mysql that returns an empty result I cant 
get it to return
"No result found" always returns "Found" even though the recoed does not 
exist...



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


- Original Message - From: "Martin Marques" 


To: "Stut" <[EMAIL PROTECTED]>
Cc: "Tijnema !" <[EMAIL PROTECTED]>; "tedd" <[EMAIL PROTECTED]>; "Peter 
Lauri" <[EMAIL PROTECTED]>; "Ólafur Waage" <[EMAIL PROTECTED]>; 


Sent: Monday, April 09, 2007 9:45 PM
Subject: Re: [PHP] Session Authentication



Stut escribió:
As with most things these days it probably breaches the DMCA. But 
frankly speaking, if doing that works then the developers of the 
application, and by extension the company, deserve everything they get.


DMCA is a real piece of crap.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |   Programador, DBA
Centro de Telemática | Administrador
   Universidad Nacional
del Litoral
-

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







$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql) OR die('[MYSQL ERROR] - ['.mysql_errno().']'.mysql_error());

while ( list($client) = mysql_fetch_row($result) ) {
echo "{$client}\n";
}


--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times 
for you and me when all such things agree.


- Rush

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



Re: [PHP] mysql if empty

2007-04-10 Thread tedd

At 10:18 PM +0100 4/9/07, <[EMAIL PROTECTED]> wrote:
If I search for something in mysql that returns an empty result I 
cant get it to return
"No result found" always returns "Found" even though the recoed does 
not exist...



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


Try NULL

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] mysql if empty

2007-04-09 Thread Satyam
An empty result is still a valid result.  As long as the SQL statement is 
valid, you will get a result set. This doesn't meant that the variable 
holding the reference to the result set is itself empty, but that you will 
fail to fetch any results from it.


Satyam

- Original Message - 
From: <[EMAIL PROTECTED]>

To: 
Sent: Monday, April 09, 2007 11:18 PM
Subject: [PHP] mysql if empty


If I search for something in mysql that returns an empty result I cant get 
it to return
"No result found" always returns "Found" even though the recoed does not 
exist...



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


- Original Message - 
From: "Martin Marques" 

To: "Stut" <[EMAIL PROTECTED]>
Cc: "Tijnema !" <[EMAIL PROTECTED]>; "tedd" <[EMAIL PROTECTED]>; "Peter 
Lauri" <[EMAIL PROTECTED]>; "Ólafur Waage" <[EMAIL PROTECTED]>; 


Sent: Monday, April 09, 2007 9:45 PM
Subject: Re: [PHP] Session Authentication



Stut escribió:
As with most things these days it probably breaches the DMCA. But 
frankly speaking, if doing that works then the developers of the 
application, and by extension the company, deserve everything they get.


DMCA is a real piece of crap.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |   Programador, DBA
Centro de Telemática | Administrador
   Universidad Nacional
del Litoral
-

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





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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.0.0/752 - Release Date: 08/04/2007 
20:34





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



Re: [PHP] mysql if empty

2007-04-09 Thread Paul Novitski

At 4/9/2007 02:18 PM, [EMAIL PROTECTED] wrote:
If I search for something in mysql that returns an empty result I 
cant get it to return
"No result found" always returns "Found" even though the recoed does 
not exist...


$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";



$result tells you whether or not the query executed successfully.  If 
($result === FALSE), look to mysql_error() for a description of the 
problem.  Otherwise, $result is the handle to the query's result.


A successful (non-error-producing) query can return zero rows of 
data.  A perfect example is when you check a user table to make sure 
a username isn't already taken before creating a new record.


Read this page again carefully:
http://php.net/mysql_query

Regards,

Paul
__

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 


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



Re: [PHP] mysql if empty

2007-04-09 Thread Davi
Em Segunda 09 Abril 2007 18:27, Lori Lay escreveu:
> [EMAIL PROTECTED] wrote:
> > If I search for something in mysql that returns an empty result I cant
> > get it to return
> > "No result found" always returns "Found" even though the recoed does
> > not exist...
> >
> >
> > $sql = "SELECT Client FROM booked WHERE Name = 'larry'";
> >
> > $result = mysql_query($sql);
> >
> > if ($result == "")
> > {
> > echo "No result found";
> > }
> > echo "Found";
>
> Use isset.
>
> if (!isset($result)) {
> echo "No result found";
> }...
>
> Lori

$result is set ($result = mysql_query($query))...
compare to 0 is satisfatory:

$result=mysql_query($query)
$results=mysql_num_rows($result)

if($results==0)
{
echo "no result found";
}
elseif($results<0)
{
echo "Some error? ".mysql_error();
}
else
{
//your code here
}


-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Agora com fortune:
"   I imagine bugs and girls have a dim perception that nature played a cruel
trick on them, but they lack the intelligence to really comprehend the
magnitude of it.  -- Calvin"

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



Re: [PHP] mysql if empty

2007-04-09 Thread Lori Lay

[EMAIL PROTECTED] wrote:
If I search for something in mysql that returns an empty result I cant 
get it to return
"No result found" always returns "Found" even though the recoed does 
not exist...



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


Use isset.

if (!isset($result)) {
   echo "No result found";
}...

Lori

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



Re: [PHP] mysql if empty

2007-04-09 Thread afan
> If I search for something in mysql that returns an empty result I cant get
> it to return
> "No result found" always returns "Found" even though the recoed does not
> exist...
>
>
> $sql = "SELECT Client FROM booked WHERE Name = 'larry'";
>
> $result = mysql_query($sql);
>
> if ($result == "")
> {
> echo "No result found";
> }
> echo "Found";

try this:

$sql = "SELECT Client FROM booked WHERE Name = 'larry'";
$result = mysql_query($sql);
if(mysql_num_rows($result) == 0)
{
  echo "No result found";
}
else
{
  $myresults = mysql_fetch_array($result);
}

-afan



>
>
> - Original Message -
> From: "Martin Marques" 
> To: "Stut" <[EMAIL PROTECTED]>
> Cc: "Tijnema !" <[EMAIL PROTECTED]>; "tedd" <[EMAIL PROTECTED]>; "Peter
> Lauri" <[EMAIL PROTECTED]>; "Ólafur Waage" <[EMAIL PROTECTED]>;
> 
> Sent: Monday, April 09, 2007 9:45 PM
> Subject: Re: [PHP] Session Authentication
>
>
>> Stut escribió:
>>> As with most things these days it probably breaches the DMCA. But
>>> frankly
>>> speaking, if doing that works then the developers of the application,
>>> and
>>> by extension the company, deserve everything they get.
>>
>> DMCA is a real piece of crap.
>>
>> --
>> select 'mmarques' || '@' || 'unl.edu.ar' AS email;
>> -
>> Martín Marqués  |   Programador, DBA
>> Centro de Telemática | Administrador
>>Universidad Nacional
>> del Litoral
>> -
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] mysql if empty

2007-04-09 Thread chris
If I search for something in mysql that returns an empty result I cant get 
it to return
"No result found" always returns "Found" even though the recoed does not 
exist...



$sql = "SELECT Client FROM booked WHERE Name = 'larry'";

$result = mysql_query($sql);

if ($result == "")
{
echo "No result found";
}
echo "Found";


- Original Message - 
From: "Martin Marques" 

To: "Stut" <[EMAIL PROTECTED]>
Cc: "Tijnema !" <[EMAIL PROTECTED]>; "tedd" <[EMAIL PROTECTED]>; "Peter 
Lauri" <[EMAIL PROTECTED]>; "Ólafur Waage" <[EMAIL PROTECTED]>; 


Sent: Monday, April 09, 2007 9:45 PM
Subject: Re: [PHP] Session Authentication



Stut escribió:
As with most things these days it probably breaches the DMCA. But frankly 
speaking, if doing that works then the developers of the application, and 
by extension the company, deserve everything they get.


DMCA is a real piece of crap.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |   Programador, DBA
Centro de Telemática | Administrador
   Universidad Nacional
del Litoral
-

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





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