473,409 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

isEMPTY

hi,

i have the following:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ...
  3. if(empty($_GET['SFT']) AND empty($_GET['fac']))
  4. {
  5. echo "one";
  6. }
  7. elseif(empty($_GET['SFT']) AND isset($_GET['fac']))
  8. {
  9. echo "two";
  10. }
  11. elseif(isset($_GET['SFT']) AND isset($_GET['fac']))
  12. {
  13. echo "three";
  14. }
  15. else
  16. {
  17. echo "four";
  18. }
  19. ...
  20.  
for some reason "three" is show for the following url:
http://localhost/REC.php?count=tuesd...20-%204PM-12AM

i think i need to add another else or something because seems like it should be displaying "four". i just need something to handle cases in which the fac is empty or no value, as seen in my url here.

thanks in advance,
geebee
Jan 27 '09 #1
11 3528
Dormilich
8,658 Expert Mod 8TB
@geraldjr30
which is totally correct, both values (fac & SFT) are set, thus fulfilling condition 3. that one of them doesn't have a value is no concern of isset().

you could simplify that by
Expand|Select|Wrap|Line Numbers
  1. isset($_GET['SFT'], $_GET['fac'])
@geraldjr30
Expand|Select|Wrap|Line Numbers
  1. !$_GET['fac'] && $_GET['SFT']
Jan 27 '09 #2
how can i handle the "fac=" part?
Jan 27 '09 #3
Dormilich
8,658 Expert Mod 8TB
@geraldjr30
what do you mean by that?
Jan 27 '09 #4
would i handle it with ISNULL for cases like this?
Jan 27 '09 #5
Dormilich
8,658 Expert Mod 8TB
either use empty($_GET['fac']) or !$_GET['fac']
Jan 27 '09 #6
TheServant
1,168 Expert 1GB
Can I recommend looking at the isset() function. It's good for $_POST and $_GET variables.
Jan 28 '09 #7
Dormilich
8,658 Expert Mod 8TB
@TheServant
that's right to first check, whether the variable you want to use actually exists. nevertheless, isset() tells you nothing about the variable's value.
Jan 28 '09 #8
is there such thing as NOT empty($_GET['fac'])?
Jan 28 '09 #9
Markus
6,050 Expert 4TB
@geraldjr30
empty() returns a boolean value (true or false) depending on the variable. You check if it's empty like so:

Expand|Select|Wrap|Line Numbers
  1. if( empty ($var) )
  2. {
  3.     ...
  4. }
  5.  
You can check if it's not empty by using the exclamation (!) symbol prior to the statement (this checks if a function returns false).
Expand|Select|Wrap|Line Numbers
  1. if( ! empty ($var) )
  2. {
  3.     ...
  4. }
  5.  
Hope this helps.
Jan 28 '09 #10
thanks... that helps!!
Jan 28 '09 #11
Markus
6,050 Expert 4TB
@geraldjr30
No problamo.

See ya around,
Markus.
Jan 28 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: gabryh | last post by:
Hi, The following code throws me NullPointerException. ..... public static boolean isEmpty(String value) { return ((value == null) || (value.trim().equals(""))); }
4
by: BUX | last post by:
They exist in Visual Studio .Net , but I do not know the name of dll to create the reference! Can you please help me?
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
2
by: RSusanto | last post by:
Hi, Is there any new function in VB .NET replacing the ISEMPTY(variable) from the old VB ?
1
by: LinkaBlack | last post by:
i m designing a solitaire ame in c++......i dont have to use graphics....just use data structure n cmd for out....for the game....i m done with the making of all the classes to b used n the basic...
13
by: B. Williams | last post by:
I have written some code to accept input and place this input at the beginning or end of a list, but I need assistance including a class so that it will allow input of a phone number that is...
10
by: AsheeG87 | last post by:
Hello Everyone! I have a linked list and am trying to include a recursive search. However, I am having trouble understanding how I would go about that. I don't quite understand a recursive...
4
by: jjh5030 | last post by:
This is a programming assignment. You are asked to work with pointers. Be aware that error messages are often not very helpful when your pointers point to bad locations. Therefore, reserve...
17
vikas251074
by: vikas251074 | last post by:
I am storing value by the following <td>Name of Person</td> <td><input type="text" width="100px" name="vname" value=<%=vname%>> </td> When I enter 'Vikas Kumar' and press enter key only...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.