Re: [PHP] empty variable

2004-09-21 Thread Chris Dowell
Just to clear up, there is no isempty() function - the correct function 
is empty() and its details can be found here: http://uk.php.net/empty

Cheers
Chris
-{ Rene Brehmer }- wrote:
At 01:54 20-09-2004, Chris Mach wrote:
What is the best way to determine if a variable is empty?
I have a feeling there is a better way than the way I'm doing it now...
if ($variable == "")

there's 2:
if (isset($variable))
or
if (isempty($variable))
what's most appropriate depends on how the variable is set or not
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] empty variable

2004-09-19 Thread Jason Davidson
if youdo 
if($var) {

}

and var doesnt exist at all, thats an error.

if(isset($var)) {

}

will test to see if $var exists, but will not test the value of var, so
$var could be blank...

Jason

"Pat" <[EMAIL PROTECTED]> wrote: 
> 
> So, you have to know, first, what is your meaning of your empty variabe:
> null, 0, "", array()?
> 
> For example, "$var = 0;", empty($var) says true... but you?
> 
> "Jason Davidson" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > as suggeted the isset and empty functions are usefull,
> > or if you know it may be set, but could be empty, how about just
> > if($variable) {
> >
> > }
> >
> > that is the same as
> > if($var == "")
> >
> > "Chris Mach" <[EMAIL PROTECTED]> wrote:
> > >
> > > What is the best way to determine if a variable is empty?
> > >
> > > I have a feeling there is a better way than the way I'm doing it now...
> > >
> > > if ($variable == "")
> > >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.766 / Virus Database: 513 - Release Date: 18-Sep-2004
> 
> -- 
> 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



Re: [PHP] empty variable

2004-09-19 Thread Pat
So, you have to know, first, what is your meaning of your empty variabe:
null, 0, "", array()?

For example, "$var = 0;", empty($var) says true... but you?

"Jason Davidson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> as suggeted the isset and empty functions are usefull,
> or if you know it may be set, but could be empty, how about just
> if($variable) {
>
> }
>
> that is the same as
> if($var == "")
>
> "Chris Mach" <[EMAIL PROTECTED]> wrote:
> >
> > What is the best way to determine if a variable is empty?
> >
> > I have a feeling there is a better way than the way I'm doing it now...
> >
> > if ($variable == "")
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.766 / Virus Database: 513 - Release Date: 18-Sep-2004

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



Re: [PHP] empty variable

2004-09-19 Thread Jason Davidson
as suggeted the isset and empty functions are usefull, 
or if you know it may be set, but could be empty, how about just
if($variable) {

}

that is the same as
if($var == "")

"Chris Mach" <[EMAIL PROTECTED]> wrote: 
> 
> What is the best way to determine if a variable is empty?
> 
> I have a feeling there is a better way than the way I'm doing it now...
> 
> if ($variable == "")
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.766 / Virus Database: 513 - Release Date: 18-Sep-2004

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



Re: [PHP] empty variable

2004-09-19 Thread -{ Rene Brehmer }-
At 01:54 20-09-2004, Chris Mach wrote:
What is the best way to determine if a variable is empty?
I have a feeling there is a better way than the way I'm doing it now...
if ($variable == "")
there's 2:
if (isset($variable))
or
if (isempty($variable))
what's most appropriate depends on how the variable is set or not
--
Rene Brehmer
aka Metalbunny
If your life was a dream, would you wake up from a nightmare, dripping of 
sweat, hoping it was over? Or would you wake up happy and pleased, ready to 
take on the day with a smile?

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums at http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] empty variable

2004-09-19 Thread Larry E . Ullman
What is the best way to determine if a variable is empty?
I have a feeling there is a better way than the way I'm doing it now...
if ($variable == "")
You could try the empty() or isset() functions, depending upon exactly 
what you're wanting to test. See the manual for descriptions of both.

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


[PHP] empty variable

2004-09-19 Thread Chris Mach
What is the best way to determine if a variable is empty?

I have a feeling there is a better way than the way I'm doing it now...

if ($variable == "")


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 18-Sep-2004

RE: [PHP] Empty Variable Values Between Scripts

2004-06-08 Thread Jay Blanchard
[snip]
Is there something that has to be done to php so that it sees these 
variables?  Is this an operating system issue?  Anything else I should
be 
looking at?
[/snip]

register globals is off, so all of your variables are in the POST array

$_POST['first']
$_POST['last']

etc. Replace all your variable references with the appropriate array
references and you'll be off to the races.

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



[PHP] Empty Variable Values Between Scripts

2004-06-08 Thread Frank Hahn
Hello:

I am just starting to learn php and have been reading tutorials that I 
have found on the Internet.

The one I am reading now is:

http://www.freewebmasterhelp.com/tutorials/phpmysql/1

The problem I am having is with these two scripts.

Script 1:

(This script displays some forms to type in Contact information.)


First Name: 
Last Name: 
Phone: 
Mobile: 
Fax: 
E-mail: 
Web: 



Script 2:

(This script (saved as insert.php) is called by Script 1 after 
information has been typed into the above form.)

Database Output";

$i=0;
while ($i < $num) {

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");

echo "$first $lastPhone: $phoneMobile: $mobileFax: 
$faxE-
mail: $emailWeb: $web";

++$i;
}

?>

I have created the database Contacts.  It is a MySQL database.  I open 
the first script and enter my contact data, press Submit, and I believe 
the second script is then called.

I go and check my Contacts database and a new record has been added, but 
it is empty.  I am guessing that the values assigned in the first script 
are not being seen by the second script and that the empty variables are 
being written to the database.

Is there something that has to be done to php so that it sees these 
variables?  Is this an operating system issue?  Anything else I should be 
looking at?

Other data:

Server Machine: Sun Sparc 20 with Solaris 2.6, Apache 2.0.49, MySQL 
4.0.17, PHP 4.3.7.
Remote Machine: Homebuilt running MS Windows 2000, Mozilla Firebird 0.7 
browser

If there is a better list for beginner questions, please let me know.

Thanks.

-- 
Frank Hahn

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