FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » AND and OR
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
AND and OR [message #182562] Fri, 16 August 2013 00:21 Go to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
Hi,

Doing code cleanup; something that seemed so simple is giving me lots of
trouble for whatever reason.

Win 7, XAMPP, PHP 5.3, online forms:

In my cleanup efforts I've been trying to concatenate statements for
things like the following:

IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
{
code; notify user of errors that must be corrected.
}

I know OR is || and AND is &&, and have tried every combination of code
I can think of but I consistently get syntax errors and it never works.
Doing each var independently works fine; e.g. if(strlen($var) == 0)
{...}, works as expected, first time every time.

It's when I start to try to use AND or OR that I get in trouble; I
continually get syntax errors, suggesting I don't know what I'm doing,
which I guess is obvious.
At one time I had a downloaded code page explaining precisely how
to OR them together, but darned if I can refind it on my hard drive OR
online either! I just cannot locate the proper way to OR vars together.

Either a code example or URL to such a feature would be great! I am just
not finding anything on Google or otherwise to demo how it works!

Thanks in Advance,

Twayne`
Re: AND and OR [message #182563 is a reply to message #182562] Fri, 16 August 2013 00:30 Go to previous messageGo to next message
Paul Herber is currently offline  Paul Herber
Messages: 26
Registered: February 2011
Karma: 0
Junior Member
On Thu, 15 Aug 2013 20:21:09 -0400, Twayne <nobody(at)spamcop(dot)net> wrote:

> Hi,
>
> Doing code cleanup; something that seemed so simple is giving me lots of
> trouble for whatever reason.
>
> Win 7, XAMPP, PHP 5.3, online forms:
>
> In my cleanup efforts I've been trying to concatenate statements for
> things like the following:
>
> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
> {
> code; notify user of errors that must be corrected.
> }

RTM, the syntax is clear.

http://php.net/manual/en/control-structures.if.php



--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ twitter: @sandrilaLtd
Re: AND and OR [message #182564 is a reply to message #182562] Fri, 16 August 2013 01:08 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Thu, 15 Aug 2013 20:21:09 -0400, Twayne wrote:
> Hi,
>
> Doing code cleanup; something that seemed so simple is giving me lots of
> trouble for whatever reason.
>
> Win 7, XAMPP, PHP 5.3, online forms:
>
> In my cleanup efforts I've been trying to concatenate statements for
> things like the following:
>
> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
1 2 1 0 1 0 * 1 0 **
> {
> code; notify user of errors that must be corrected.
> }
>


--
40. I will be neither chivalrous nor sporting. If I have an unstoppable
superweapon, I will use it as early and as often as possible instead
of keeping it in reserve.
--Peter Anspach's list of things to do as an Evil Overlord
Re: AND and OR [message #182566 is a reply to message #182562] Fri, 16 August 2013 07:52 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kujr9n$il7$1(at)speranza(dot)aioe(dot)org>,
Twayne <nobody(at)spamcop(dot)net> wrote:

> Hi,
>
> Doing code cleanup; something that seemed so simple is giving me lots of
> trouble for whatever reason.
>
> Win 7, XAMPP, PHP 5.3, online forms:
>
> In my cleanup efforts I've been trying to concatenate statements for
> things like the following:
>
> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
> {
> code; notify user of errors that must be corrected.
> }

Come on you hairy fathead this is trivial stuff. Your parens are not
balanced.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: AND and OR [message #182567 is a reply to message #182562] Fri, 16 August 2013 10:25 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 16/08/13 01:21, Twayne wrote:
> Hi,
>
> Doing code cleanup; something that seemed so simple is giving me lots
> of trouble for whatever reason.
>
> Win 7, XAMPP, PHP 5.3, online forms:
>
> In my cleanup efforts I've been trying to concatenate statements for
> things like the following:
>
> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
> {
> code; notify user of errors that must be corrected.
> }
>
> I know OR is || and AND is &&, and have tried every combination of
> code I can think of but I consistently get syntax errors and it never
> works.
> Doing each var independently works fine; e.g. if(strlen($var) == 0)
> {...}, works as expected, first time every time.
>

your brackets are screwed.

if ((strlen(var1) == 0) || (strlen(var2) == 0) || (strlen(var3) ==0))

will work
as will
if (strlen(var1) == 0 || strlen(var2) == 0 || strlen(var3) ==0)

> It's when I start to try to use AND or OR that I get in trouble; I
> continually get syntax errors, suggesting I don't know what I'm doing,
> which I guess is obvious.
> At one time I had a downloaded code page explaining precisely how
> to OR them together, but darned if I can refind it on my hard drive OR
> online either! I just cannot locate the proper way to OR vars together.
>
> Either a code example or URL to such a feature would be great! I am
> just not finding anything on Google or otherwise to demo how it works!
>
> Thanks in Advance,
>
> Twayne`


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: AND and OR [message #182569 is a reply to message #182567] Fri, 16 August 2013 10:48 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
> On 16/08/13 01:21, Twayne wrote:
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots
>> of trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {
>> code; notify user of errors that must be corrected.
>> }
>>
>> I know OR is || and AND is &&, and have tried every combination of
>> code I can think of but I consistently get syntax errors and it never
>> works.
>> Doing each var independently works fine; e.g. if(strlen($var) == 0)
>> {...}, works as expected, first time every time.
>>
>
> your brackets are screwed.
>
> if ((strlen(var1) == 0) || (strlen(var2) == 0) || (strlen(var3) ==0))
>
> will work
> as will
> if (strlen(var1) == 0 || strlen(var2) == 0 || strlen(var3) ==0)
>

As well as:

if (!strlen(var1) || !strlen(var2) || !strlen(var3))


--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
Re: AND and OR [message #182570 is a reply to message #182563] Fri, 16 August 2013 11:08 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
Am 16.08.2013 02:30, schrieb Paul Herber:
> On Thu, 15 Aug 2013 20:21:09 -0400, Twayne <nobody(at)spamcop(dot)net> wrote:
>
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots of
>> trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {
>> code; notify user of errors that must be corrected.
>> }
>
> RTM, the syntax is clear.
>
> http://php.net/manual/en/control-structures.if.php

ACK.

Regarding the syntax of variables the following seems to also be
recommendable:

<http://www.php.net/manual/en/language.variables.basics.php>

--
Christoph M. Becker
Re: AND and OR [message #182571 is a reply to message #182569] Fri, 16 August 2013 11:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 16/08/13 11:48, Norman Peelman wrote:
> On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
>> On 16/08/13 01:21, Twayne wrote:
>>> Hi,
>>>
>>> Doing code cleanup; something that seemed so simple is giving me lots
>>> of trouble for whatever reason.
>>>
>>> Win 7, XAMPP, PHP 5.3, online forms:
>>>
>>> In my cleanup efforts I've been trying to concatenate statements for
>>> things like the following:
>>>
>>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>>> {
>>> code; notify user of errors that must be corrected.
>>> }
>>>
>>> I know OR is || and AND is &&, and have tried every combination of
>>> code I can think of but I consistently get syntax errors and it never
>>> works.
>>> Doing each var independently works fine; e.g. if(strlen($var) == 0)
>>> {...}, works as expected, first time every time.
>>>
>>
>> your brackets are screwed.
>>
>> if ((strlen(var1) == 0) || (strlen(var2) == 0) || (strlen(var3) ==0))
>>
>> will work
>> as will
>> if (strlen(var1) == 0 || strlen(var2) == 0 || strlen(var3) ==0)
>>
>
> As well as:
>
> if (!strlen(var1) || !strlen(var2) || !strlen(var3))
>
>
Yebbut, for twayne, that may be taking things a step too far..

many many years ago when I was a real noob and learning C without the
benefit of any training courses, I had to revisit some code to find two
bugs in it. The new person who had taken over asked me why I had never
used a particular language construct. I replied 'because at the time, I
didn't know it existed'

Trainee coders are often dumped into maintenance. One should be kind to
them. And with advances in modern compilers, there is no speed or
compiled code size penalty in being explicit at the source code level.

We were all noobs once.

--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: AND and OR [message #182572 is a reply to message #182566] Fri, 16 August 2013 15:19 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 3:52 AM, Tim Streater wrote:
> In article <kujr9n$il7$1(at)speranza(dot)aioe(dot)org>,
> Twayne <nobody(at)spamcop(dot)net> wrote:
>
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots
>> of trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {
>> code; notify user of errors that must be corrected.
>> }
>
> Come on you hairy fathead this is trivial stuff. Your parens are not
> balanced.
>

Hmm. you can be pretty much a trolling idiot at times, huh? A "normal"
person would just not bother to read, let alone waste time responding in
such manner. I'll not be reading your useless posts any longer so flop
around on the dock all you want. Oh, and enjoy!
Re: AND and OR [message #182573 is a reply to message #182567] Fri, 16 August 2013 15:42 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 6:25 AM, The Natural Philosopher wrote:
> On 16/08/13 01:21, Twayne wrote:
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots
>> of trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {

>> ...

>>
>
> your brackets are screwed.
>
> if ((strlen(var1) == 0) || (strlen(var2) == 0) || (strlen(var3) ==0))
>
> will work
> as will
> if (strlen(var1) == 0 || strlen(var2) == 0 || strlen(var3) ==0)
>

Hmm, thanks. I'll look into those formats.

Thanks much,

Twayne`

....
Re: AND and OR [message #182574 is a reply to message #182569] Fri, 16 August 2013 15:53 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 6:48 AM, Norman Peelman wrote:
> On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
>> On 16/08/13 01:21, Twayne wrote:
>>> Hi,
>>>
>>> Doing code cleanup; something that seemed so simple is giving me lots
>>> of trouble for whatever reason.
>>>

....

>
> As well as:
>
> if (!strlen(var1) || !strlen(var2) || !strlen(var3))
>
>

That looks familiar; as in, the sample I wasn't able to re-find; Thanks
Much! The sample code was, I think, an isset() or a mail() setup, but
same difference.

Regards,

Twayne`
Re: AND and OR [message #182575 is a reply to message #182571] Fri, 16 August 2013 16:10 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 7:24 AM, The Natural Philosopher wrote:
> On 16/08/13 11:48, Norman Peelman wrote:
>> On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
>>> On 16/08/13 01:21, Twayne wrote:
>>>> Hi,
>>>>
>>>> Doing code cleanup; something that seemed so simple is giving me lots
>>>> of trouble for whatever reason.
>>>>

....

>>
>> As well as:
>>
>> if (!strlen(var1) || !strlen(var2) || !strlen(var3))
>>
>>
> Yebbut, for twayne, that may be taking things a step too far..

Perhaps, but I don't think so. While many things in PHP are still
unknown to me, a lot is known to me. I've gained a LOT of knowledge over
the last few months and have put 99% of it to use. My goal hasn't been
to learn all there is about PHP and likely never will be since IMO
learning how/where to find answers, understand the syntax properly,
error checking, sessions, arrays and the like have been my recent goals.
I write online PHP forms for websites and that's where my attentions are
focused until I know them well. The "manual" at php.net and w3 schools
IMO are the best "bibles" plus a few other places like NAS and Tizag are
pretty good too, among others.

>
> many many years ago when I was a real noob and learning C without the
> benefit of any training courses, I had to revisit some code to find two
> bugs in it. The new person who had taken over asked me why I had never
> used a particular language construct. I replied 'because at the time, I
> didn't know it existed'
>
> Trainee coders are often dumped into maintenance. One should be kind to
> them. And with advances in modern compilers, there is no speed or
> compiled code size penalty in being explicit at the source code level.
>
> We were all noobs once.
>

While I appreciate your attitude toward noobies, I've found over the
years that words such as this are never understood by over-sized ego's
or OTOH might draw some flames. I've come across several of that type on
other newsgroups and forums I participate on. Mostly it's best just to
ignore their posts. Personally I'll usually respond in kind to such a
thing one time and then simply ignore them.

I do thank you for your attitude, however,

Twayne`
Re: AND and OR [message #182576 is a reply to message #182563] Fri, 16 August 2013 16:14 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-15 8:30 PM, Paul Herber wrote:
> On Thu, 15 Aug 2013 20:21:09 -0400, Twayne <nobody(at)spamcop(dot)net> wrote:
>
>> Hi,
>>
>> Doing code cleanup; something that seemed so simple is giving me lots of
>> trouble for whatever reason.
>>
>> Win 7, XAMPP, PHP 5.3, online forms:
>>
>> In my cleanup efforts I've been trying to concatenate statements for
>> things like the following:
>>
>> IF(strlen(var1) == 0) OR strlen(var2) == 0) OR strlen(var3) ==0))
>> {
>> code; notify user of errors that must be corrected.
>> }
>
> RTM, the syntax is clear.
>
> http://php.net/manual/en/control-structures.if.php
>
>
>

No, it's not clear at all. The only reference to my query is a few lines
in a 2-year old post and it's not definitve. I've not only read that
before, but have it on disc.
Re: AND and OR [message #182577 is a reply to message #182575] Fri, 16 August 2013 16:35 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 16/08/13 17:10, Twayne wrote:
> On 2013-08-16 7:24 AM, The Natural Philosopher wrote:
>> On 16/08/13 11:48, Norman Peelman wrote:
>>> On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
>>>> On 16/08/13 01:21, Twayne wrote:
>>>> > Hi,
>>>> >
>>>> > Doing code cleanup; something that seemed so simple is giving me lots
>>>> > of trouble for whatever reason.
>>>> >
>
> ...
>
>>>
>>> As well as:
>>>
>>> if (!strlen(var1) || !strlen(var2) || !strlen(var3))
>>>
>>>
>> Yebbut, for twayne, that may be taking things a step too far..
>
> Perhaps, but I don't think so. While many things in PHP are still
> unknown to me, a lot is known to me. I've gained a LOT of knowledge
> over the last few months and have put 99% of it to use. My goal hasn't
> been to learn all there is about PHP and likely never will be since
> IMO learning how/where to find answers, understand the syntax
> properly, error checking, sessions, arrays and the like have been my
> recent goals. I write online PHP forms for websites and that's where
> my attentions are focused until I know them well. The "manual" at
> php.net and w3 schools IMO are the best "bibles" plus a few other
> places like NAS and Tizag are pretty good too, among others.
>

well counting left and right brackets is fundamental programming, and
someone who makes such a basic mistake *and doesn't see it* is pretty
new to the game.

As I said, the ! operator is less intuitive than '==0' to me anyway,
though after years of C its second nature.


>>
>> many many years ago when I was a real noob and learning C without the
>> benefit of any training courses, I had to revisit some code to find two
>> bugs in it. The new person who had taken over asked me why I had never
>> used a particular language construct. I replied 'because at the time, I
>> didn't know it existed'
>>
>> Trainee coders are often dumped into maintenance. One should be kind to
>> them. And with advances in modern compilers, there is no speed or
>> compiled code size penalty in being explicit at the source code level.
>>
>> We were all noobs once.
>>
>
> While I appreciate your attitude toward noobies, I've found over the
> years that words such as this are never understood by over-sized ego's
> or OTOH might draw some flames. I've come across several of that type
> on other newsgroups and forums I participate on. Mostly it's best just
> to ignore their posts. Personally I'll usually respond in kind to such
> a thing one time and then simply ignore them.
>
by definition at this particular game you ARE a noob. or you wouldn't
have missed the unmatched brackets. I ceratyinly d0nt see that as any
reflection on unerlying intelligence...teh first program I wrte in
assembler I copied exactly out of a book. It didnt assemble. Then I took
the line numbers out. It still didn't assemble. Then I removed all
leading spaces from every line. That did work. That took two 4 hour
sessions of frustration.

I wasn't stupid. I simply had no idea, nor did the documentation say,
that line numbers and spaces were tabu.



> I do thank you for your attitude, however,
>
> Twayne`


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: AND and OR [message #182578 is a reply to message #182577] Fri, 16 August 2013 16:47 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kulkcc$39s$1(at)news(dot)albasani(dot)net>,
The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:

> by definition at this particular game you ARE a noob. or you wouldn't
> have missed the unmatched brackets.

Not necessarily. Anyone can miss them if they are tired etc. But we then
find them after a while. I'd say no one should be coming here with
missed brackets unless they've spent some time looking and can't find it.

There again, I use TextWrangler. This allows me to double click just
inside any bracket or paren, and it highlights everything up to the
matching closing bracket or paren. That will tell you straight away that
you've got a missing one, or, by descending into it, whether you got
them *correctly* matched.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: AND and OR [message #182579 is a reply to message #182578] Fri, 16 August 2013 17:13 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 16/08/13 17:47, Tim Streater wrote:
> In article <kulkcc$39s$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
>> by definition at this particular game you ARE a noob. or you wouldn't
>> have missed the unmatched brackets.
>
> Not necessarily. Anyone can miss them if they are tired etc. But we
> then find them after a while. I'd say no one should be coming here
> with missed brackets unless they've spent some time looking and can't
> find it.
>
> There again, I use TextWrangler. This allows me to double click just
> inside any bracket or paren, and it highlights everything up to the
> matching closing bracket or paren. That will tell you straight away
> that you've got a missing one, or, by descending into it, whether you
> got them *correctly* matched.
>
well I use geany, and unmatched anything tends to go red..

I wasnt objecting to the error, but bringing it here. I'd say I
generally have an unmatched bracket for every 20 or so brackets I type :-)


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: AND and OR [message #182595 is a reply to message #182575] Sat, 17 August 2013 14:19 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Fri, 16 Aug 2013 12:10:43 -0400, Twayne <nobody(at)spamcop(dot)net> wrote:

> On 2013-08-16 7:24 AM, The Natural Philosopher wrote:
>> On 16/08/13 11:48, Norman Peelman wrote:
>>> On 08/16/2013 06:25 AM, The Natural Philosopher wrote:
>>>> On 16/08/13 01:21, Twayne wrote:
>>>> > Hi,
>>>> >
>>>> > Doing code cleanup; something that seemed so simple is giving me lots
>>>> > of trouble for whatever reason.
>>>> >
>
> ...
>
>>>
>>> As well as:
>>>
>>> if (!strlen(var1) || !strlen(var2) || !strlen(var3))
>>>
>>>
>> Yebbut, for twayne, that may be taking things a step too far..
>
> Perhaps, but I don't think so. While many things in PHP are still
> unknown to me, a lot is known to me. I've gained a LOT of knowledge over
> the last few months and have put 99% of it to use.

From my limited perspective, your greatest gap is in techniques for
systematically identifying errors. The two most recent were: not being
checking if session variables were making it to the script, and
unbalanced parentheses. The methods for finding these types of errors
are not language-specific.
Re: AND and OR [message #182596 is a reply to message #182579] Sat, 17 August 2013 14:20 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Fri, 16 Aug 2013 18:13:01 +0100, The Natural Philosopher
<tnp(at)invalid(dot)invalid> wrote:

> I wasnt objecting to the error, but bringing it here. I'd say I
> generally have an unmatched bracket for every 20 or so brackets I type :-)

For me it's every 19...
Re: AND and OR [message #182597 is a reply to message #182596] Sat, 17 August 2013 14:36 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 17/08/13 15:20, Richard Yates wrote:
> On Fri, 16 Aug 2013 18:13:01 +0100, The Natural Philosopher
> <tnp(at)invalid(dot)invalid> wrote:
>
>> I wasnt objecting to the error, but bringing it here. I'd say I
>> generally have an unmatched bracket for every 20 or so brackets I type :-)
> For me it's every 19...
and about every third function call the throws 'unknownfunction' due to
mistyping the name..
...i now have a browser window that by some secret magic allows me to
view the error log files on a distant machine..purely to seed up
typograhical debugging.


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
Re: AND and OR [message #182600 is a reply to message #182577] Sat, 17 August 2013 17:22 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 12:35 PM, The Natural Philosopher wrote:
....

>
> well counting left and right brackets is fundamental programming, and
> someone who makes such a basic mistake *and doesn't see it* is pretty
> new to the game. Whether the brackets matched or not in the presented
code wasn't checked closely, and likely should have been; it's but one
of several tries
I made where the bracket matches checked fine in my Editor. However, the
bracket problem was a bit more than just a missing bracket; I misplaced
them and badly.

No arguement there.
>
> As I said, the ! operator is less intuitive than '==0' to me anyway,
> though after years of C its second nature.

Well, I unfortunetaly don't have a C history, but I do often the find
the ! operator quite useful and often a way to have less code in that
often no ELSE is needed that way. Which BTW is now my current interest;
minimizing the amount of code used and still have it more or less
self-documenting.

Cheers,

Twayne`

>
>

....
Re: AND and OR [message #182601 is a reply to message #182578] Sat, 17 August 2013 17:27 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 12:47 PM, Tim Streater wrote:
> In article <kulkcc$39s$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>
....
>
> There again, I use TextWrangler. This allows me to double click just
> inside any bracket or paren, and it highlights everything up to the
> matching closing bracket or paren. That will tell you straight away that
> you've got a missing one, or, by descending into it, whether you got
> them *correctly* matched.
>

Many text editors, including my own, work much the same way. NoteTab Pro
and NotePad++ to mention two of them I use most. They're all also
capable of knowing when a file has been changed and offers to reload the
most recent versions etc.

Twayne`
Re: AND and OR [message #182605 is a reply to message #182597] Sat, 17 August 2013 17:47 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Sat, 17 Aug 2013 15:36:22 +0100, The Natural Philosopher
<tnp(at)invalid(dot)invalid> wrote:

> On 17/08/13 15:20, Richard Yates wrote:
>> On Fri, 16 Aug 2013 18:13:01 +0100, The Natural Philosopher
>> <tnp(at)invalid(dot)invalid> wrote:
>>
>>> I wasnt objecting to the error, but bringing it here. I'd say I
>>> generally have an unmatched bracket for every 20 or so brackets I type :-)
>> For me it's every 19...

> and about every third function call the throws 'unknownfunction' due to
> mistyping the name..

I'm down to an error rate of 30% on = instead of == in if clauses.

> ...purely to seed up typograhical debugging.

I guess it doesn't work on Usenet.
Re: AND and OR [message #182608 is a reply to message #182605] Sat, 17 August 2013 18:05 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-17 1:47 PM, Richard Yates wrote:
> On Sat, 17 Aug 2013 15:36:22 +0100, The Natural Philosopher
> <tnp(at)invalid(dot)invalid> wrote:
>
....
>
> I'm down to an error rate of 30% on = instead of == in if clauses.
>
>> ...purely to seed up typograhical debugging.
>
> I guess it doesn't work on Usenet.
>

Maybe I can offer a possible help for some of that. If you editor
allows you to, create clips or libraries so when you click them, they'll
enter for you:
?PHP>

?>

or

HTML comment:
<!-- -->

PHP Comment Start:
if() === "" ) {

}

and it's especially useful for anything of more than a few characters,
like $referrer, session functions, etc etc etc.

and so forth. By entering everything but the var & what goes between the
"", you at least know all the surrounding code is current.

Also things like: <!DOCTYPE html> , <form action =, name=, et al
including the end form & end HTML. It has a lot of uses once you create
your own library or clip code.

There are of course complete libraries availble for PHP and HTML, C, and
more, but in general I seldom use them unless I need to look up
something I haven't done before. One does of course need to have the
disclipine to update the clip/library as early as possible and to
delete/replace the ones that are needed.
It speeds up coding like nobody's business once it's set with your
own often used or lengthy pieces of code.

Cheers,

Twayne`
Re: AND and OR [message #182610 is a reply to message #182605] Sat, 17 August 2013 18:40 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 17/08/13 18:47, Richard Yates wrote:
> On Sat, 17 Aug 2013 15:36:22 +0100, The Natural Philosopher
> <tnp(at)invalid(dot)invalid> wrote:
>
>> On 17/08/13 15:20, Richard Yates wrote:
>>> On Fri, 16 Aug 2013 18:13:01 +0100, The Natural Philosopher
>>> <tnp(at)invalid(dot)invalid> wrote:
>>>
>>>> I wasnt objecting to the error, but bringing it here. I'd say I
>>>> generally have an unmatched bracket for every 20 or so brackets I type :-)
>>> For me it's every 19...
>> and about every third function call the throws 'unknownfunction' due to
>> mistyping the name..
> I'm down to an error rate of 30% on = instead of == in if clauses.
>
>> ...purely to seed up typograhical debugging.
> I guess it doesn't work on Usenet.
>
:-)

no, sadly not :-(


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Function Problem
Next Topic: switch with case 0
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 04:05:06 GMT 2024

Total time taken to generate the page: 0.02657 seconds