473,508 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to compare null string

236 New Member
Hi all,

I did the null string comparison for below...

But could not work as i keyed some value into the $company field but it did not print out okok, but not ok. I used if ($company != '') also did not help...

Can you kindly advise?


Cheers...
Andrew

Expand|Select|Wrap|Line Numbers
  1. if ($company != "" )
  2. {
  3.  
  4.   print "okok \n";
  5. }
  6. else
  7. {
  8.  
  9.   print "Not ok \n";
  10. }
  11.  
Dec 5 '08 #1
14 14661
happyse27
236 New Member
Hi all,

I used eq as it is string.. but still didnt work..

Cheers...
Andrew

Expand|Select|Wrap|Line Numbers
  1. if ($company eq "" )
  2. {
  3.  
  4.   print "okok \n";
  5. }
  6. else
  7. {
  8.  
  9.   print "Not ok \n";
  10. }
  11.  
Dec 5 '08 #2
happyse27
236 New Member
Hi all,

Any advise..?


Cheers...
Andrew
Dec 5 '08 #3
KevinADC
4,059 Recognized Expert Specialist
Use "ne" instead of "!=". There are string operators and math operators, use the correct ones depending on what you are trying to compare.
Dec 5 '08 #4
KevinADC
4,059 Recognized Expert Specialist
see below...
Dec 5 '08 #5
KevinADC
4,059 Recognized Expert Specialist
@happyse27
Andrew, this is not tech support. You're asking after 5 minutes if anyone can advise after posting your last question. You need to be more patient than that.
Dec 5 '08 #6
happyse27
236 New Member
ok. sorry...

can kindly assist Sirs?
Dec 5 '08 #7
KevinADC
4,059 Recognized Expert Specialist
I already did, I advised you to use "ne" instead of "!=".
Dec 5 '08 #8
Ganon11
3,652 Recognized Expert Specialist
You can also simply use $company, since the null string is a FALSE value:

Expand|Select|Wrap|Line Numbers
  1. if ($company) {
  2.    print "It's not null.\n";
  3. } else {
  4.    print "It's null.\n";
  5. }
Dec 6 '08 #9
KevinADC
4,059 Recognized Expert Specialist
@Ganon11
Good observation. But thats also true if $company is equal to 0 which perl considers a false value:

$company = 0;

something for the unwary to keep in mind.
Dec 6 '08 #10
happyse27
236 New Member
Thanks Sirs... It worked... Cheers...
Dec 8 '08 #11
happyse27
236 New Member
Hi Moderator,

Why I am not allow to post new thread? What rules did I violate? And I wasnt intentional... Not even a chance can be given?

Regards,
Andrew
Dec 8 '08 #12
KevinADC
4,059 Recognized Expert Specialist
This website has been undergoing a lot of changes lately and if you can't post a new thread is probably something to do with the changes. Try again.
Dec 8 '08 #13
Ganon11
3,652 Recognized Expert Specialist
happyse27,

Just to reiterate what KevinADC said, I don't think you've done anything to warrant any sort of 'posting ban'. It was likely an error due to our changing interface. Please try again.
Dec 9 '08 #14
happyse27
236 New Member
Thanks Again. Sirs.. Appreciated...
Really needed help...

Btw, how to get above country / province modules, it is to register username and passwords and also the country, the state(province) for the people who serve, country::locale seemed to be incomplete.


Cheers...
Andrew
Dec 9 '08 #15

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

Similar topics

4
33542
by: DiggidyMack69 | last post by:
I have a sql resultset called columns. When I convert an integer column to string that is a NULL it converts to zero. How can I get it to convert to null?? String x; x =...
1
8343
by: Laurent Liegeois | last post by:
Hi, I have a funny Error in our sql server 7 & 2000. When I compare two string in Unicode format. I receive that it is the same when I add new nchar. I don’t understand why? Could you...
2
8692
by: Robert Kattke | last post by:
I'm getting a TransformerException when running Tomcat and calling a Servlet that use XML to create DOM and XSL to create webpage. I'm posting just the snippet of XSL code and the Error here. ...
5
2435
by: VMI | last post by:
How can I validate a null string or an empty string in the same IF statement? If I use this: if (myString.Trim().Length <= 0 || myString == null) { //do stuff } I'll get a run-time error...
5
1484
by: John Smith | last post by:
How can I detect a NULL string using C# ? Thanks.
3
4907
by: dotnetnoob | last post by:
i have two strings from xml file str1 = 800.7415_801.101_8.115_216.12 str2 = 800.7415_801.101_8.115_216.12_217.570 the first stream represent a xml file 800.7415_801.101_8.115_261.12.xml...
2
2234
by: bill | last post by:
from: http://us3.php.net/mysql_real_escape_string // Quote variable to make safe function quote_smart($value) { // Stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); }...
10
9034
by: lovecreatesbea... | last post by:
Is it correct and safe to compare a string object with "", a pair of quotation marks quoted empty string?If the string object: s = ""; does s contain a single '\'? Is it better to use...
9
10030
by: Plissken.s | last post by:
Hi, how can i compare a string which is non null and empty? i look thru the string methods here, but cant find one which does it? ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
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
7380
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
5626
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,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
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...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.