473,799 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Probs with strlen ??

Hello,

I'm doing like this:

if (strlen($Name_v or) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vo r) before the condition and it is definivly
0

From te manual strlen returns an INT.

What is wrong ??

TIA

Hanjo
--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Aug 28 '05 #1
6 1593
Hanjo Grüßner wrote:
Hello,

I'm doing like this:

if (strlen($Name_v or) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vo r) before the condition and it is
definivly
0


There might be a previous condition overwriting this one. BTW, as anything
above 0 evaluates as TRUE in PHP, you could simply do:

if (strlen($Name_v or))
echo '</table></fieldset>';

Or even:

if ($Name_vor)
echo '</table></fieldset>';
JW

Aug 28 '05 #2
max
On Sun, 28 Aug 2005 13:41:34 +0200, Hanjo Grüßner <ha***@gruessne r.de>
wrote:
Hello,

I'm doing like this:

if (strlen($Name_v or) > 0)
echo '</table></fieldset>';
But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vo r) before the condition and it is definivly
0

From te manual strlen returns an INT.

What is wrong ??

TIA

Hanjo

If you're just checking that $Name_vor has a length (and, thus, that it
exists) can you not go -

if ($Name_vor) do_such_and_suc h;

Have you had a look at www.php.net/strlen ? One of the contributions there
helped me solve a problem -

QUOTE
Beware: strlen() counts new line characters at the end of a string, too!

$a = "123\n";
echo "<p>".strlen($a )."</p>";

The above code will output 4.
UNQUOTE
Aug 28 '05 #3
On Sun, 28 Aug 2005 13:41:34 +0200, Hanjo Grüßner <ha***@gruessne r.de> wrote:
I'm doing like this:

if (strlen($Name_v or) > 0)
echo '</table></fieldset>';

But the program never goes into the 'echo' branch.

I tried to get strlen($Name_vo r) before the condition and it is definivly
0


From te manual strlen returns an INT.

What is wrong ??


Can you post a minimal test case reproducing the problem?

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 28 '05 #4
On Sun, 28 Aug 2005 12:28:56 GMT, max <ma****@homtail .com> wrote:
If you're just checking that $Name_vor has a length (and, thus, that it
exists) can you not go -

if ($Name_vor) do_such_and_suc h;


Not the same. Consider: $Name_vor = '0';

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Aug 28 '05 #5
Am Sun, 28 Aug 2005 14:38:00 +0200 schrieb Andy Hassall <an**@andyh.co. uk>:

Can you post a minimal test case reproducing the problem?


Thanks, I found the mistake - as stupid as it could be:

I wrote $Name_vor instead of $Name_Vor

Greetings from the sunny shores of the baltic sea

Hanjo
--
Software & Seminar-Kontor Hans-Joachim Grüßner
Glasholz
D-24369 Waabs
http://www.gruessner.de
Aug 28 '05 #6
=?iso-8859-15?Q?Hanjo_Gr=F C=DFner?= <ha***@gruessne r.de> wrote:
Thanks, I found the mistake - as stupid as it could be:
I wrote $Name_vor instead of $Name_Vor


You have learnt your lesson well grasshopper. Switch on all errors and
warnings and declare your variables before using them.

Bill, fwsh fwsh.

--
http://billpg.me.uk/ usenet(at)billp g(dot)me(dot)uk
Aug 28 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1980
by: Arijit Chatterjee | last post by:
Hi Everybody, I am facing another probs. I have created a trigger for table Tab1 for perticular column col1 for checking value ranges.But at time for using insert statement it is working fine but when I am importing data from flat file through DTS the trigger is not working.How to solve this. Regards Arijit Chatterjee
21
8491
by: sugaray | last post by:
hi, it just came up my mind that since we can get the length of any given string literal S with 'sizeof S-1', so, what's the merit of library function strlen()'s existence ? thanx in advance for your instruction.
81
7358
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there be any advantage in having strcat and strcpy return a pointer to the "end" of the destination string rather than returning a
33
2978
by: apropo | last post by:
what is wrong with this code? someone told me there is a BAD practice with that strlen in the for loop, but i don't get it exactly. Could anyone explain me in plain english,please? char *reverse(char *s) { int i; char *r; if(!s) return NULL;//ERROR r=calloc(strlen(s)+1,sizeof(char));
66
7792
by: roy | last post by:
Hi, I was wondering how strlen is implemented. What if the input string doesn't have a null terminator, namely the '\0'? Thanks a lot Roy
83
15635
by: rahul8143 | last post by:
hello, what is difference between sizeof("abcd") and strlen("abcd")? why both functions gives different output when applied to same string "abcd". I tried following example for that. #include <stdio.h> #include <string.h> void main() { char *str1="abcd";
2
2265
by: Chris | last post by:
Hi there, I have been reading in this group for a while really enjoy this pool of infinite c wisdom. :) Anyway, I have question now. I have this little piece of code that is giving me a headache. #include <stdio.h> #include <string.h>
53
717
by: ¬a\\/b | last post by:
strlen is wrong because can not report if there is some error e.g. char *a; and "a" point to an array of size=size_t max that has no 0 in it
0
9544
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.