[PHP] Little question
Hi, Folks... I have this little snippet of code: Orario: It should print a little table with the string "MY STRING"... ... unfortunately, it doesn't. Any suggestion BTW: I run this code on the following configuration: PHP Version: 4.0.4pl1 MySQL API version: 3.23.22-beta Server API: httpd on a RHLinux 7.1 Thanks in advance Gabriele Biondo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Little question
This snippet should be used as an example of badly written and presented code. It tries too hard to do a simple job and in the result fails dismally. I suggest Gabrielle, that you try to be a little more careful in your coding and not so smart. I can find no less than four errors that I put down to poorly constructed code rather than poor syntax. As a hint, why are you trying to nest cals to PHP - your " Hi, Folks... > I have this little snippet of code: > > > > > >size="2"">Orario: > > > > It should print a little table with the string "MY STRING"... > ... unfortunately, it doesn't. > > Any suggestion > > BTW: I run this code on the following configuration: > > PHP Version: 4.0.4pl1 > MySQL API version: 3.23.22-beta > Server API: httpd on a RHLinux 7.1 > > Thanks in advance > > Gabriele Biondo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Little question
this : if ... $myOra="" ... should be more like : if ... $myOra == "" ... essentially you're setting $myOra as blank everytime which evaluates to true, then it ends up printing the blank, which is not good. regarding typos, this is a common one and since it reveals no error ... it can be frustrating! :) you have others but this is the big one. and for informational purposes : http://php.net/manual/en/control-structures.php http://php.net/manual/en/language.operators.comparison.php regards, philip > > I have this little snippet of code: > > > > > $myOra="MY STRING" > > > if (!(empty($myOra) || $myOra="")){ > ?> > > > > > > > > > size="2"">Orario: > > > > > } endif > ?> > > > > It should print a little table with the string "MY STRING"... > > ... unfortunately, it doesn't. > > > > Any suggestion > > > > BTW: I run this code on the following configuration: > > > > PHP Version: 4.0.4pl1 > > MySQL API version: 3.23.22-beta > > Server API: httpd on a RHLinux 7.1 > > > > Thanks in advance > > > > Gabriele Biondo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Little question
A good approach to prevent this is to always put your constants on the lefthand side of the condition. This causes a parser error if you accidently try and assign instead of compare. It takes a bit of getting used to, but once you get into the swing of it you'll find it a useful tool in your arsenal of weapons against accidental bugs. So, the previous example would read: if ... "" == $myOra ... <--- This is correct whereas: if ... "" = $myOra ... <--- This would cause a parser error, you'd see the mistake immediately -Original Message- From: Philip Olson [mailto:[EMAIL PROTECTED]] Sent: 09 May 2001 10:23 To: Gabriele Biondo Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Little question this : if ... $myOra="" ... should be more like : if ... $myOra == "" ... essentially you're setting $myOra as blank everytime which evaluates to true, then it ends up printing the blank, which is not good. regarding typos, this is a common one and since it reveals no error ... it can be frustrating! :) you have others but this is the big one. and for informational purposes : http://php.net/manual/en/control-structures.php http://php.net/manual/en/language.operators.comparison.php regards, philip > > I have this little snippet of code: > > > > > $myOra="MY STRING" > > > if (!(empty($myOra) || $myOra="")){ > ?> > > > > > > > > > size="2"">Orario: > > > > > } endif > ?> > > > > It should print a little table with the string "MY STRING"... > > ... unfortunately, it doesn't. > > > > Any suggestion > > > > BTW: I run this code on the following configuration: > > > > PHP Version: 4.0.4pl1 > > MySQL API version: 3.23.22-beta > > Server API: httpd on a RHLinux 7.1 > > > > Thanks in advance > > > > Gabriele Biondo -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] R: [PHP] Little question
Already added, nothing changed at all... > -Messaggio originale- > Da: Jason Murray [mailto:[EMAIL PROTECTED]] > Inviato: mercoledì 9 maggio 2001 9.56 > A: 'Gabriele Biondo' > Oggetto: RE: [PHP] Little question > > > > > This needs to have a ?> after it... > > Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] R: [PHP] Little question
> this : > > if ... $myOra="" ... > > should be more like : > > if ... $myOra == "" ... > > essentially you're setting $myOra as blank everytime which evaluates to > true, then it ends up printing the blank, which is not good. regarding > typos, this is a common one and since it reveals no error ... it can be > frustrating! :) you have others but this is the big one. Thanks!!! I was really naive!!! The other errors were all fixed (lots of them were caused by a Copy-paste operation from UE to OE...) Anyway you were really helpful Thanks a lot -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]