473,396 Members | 1,734 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,396 software developers and data experts.

Very Weird Behavior

I started with the following code in an included file:

$CompanyBlock =
"$Company (Booth#: $Booth)\n".
"$Address\n".
"$City, $State $PostalCode\n".
"$Website\n".
"$Contact1, $Title1\n".
"Tel: $Phone\n".
"Fax: $Fax\n".
"Email: $Email1\n".
"Products/Services: $ProductService\n".
"Objectives: ";

I wanted to make some of the items conditional, but in so doing, I forgot
to change some of the . to ; and ended up with:

$CompanyBlock = $Company;
if ($Booth) $CompanyBlock.= " (Booth#: $Booth)";

$CompanyBlock.=
"\n".
"$Address\n".
"$City, $State $PostalCode\n";

if ($Website) $CompanyBlock.= "$Website\n";
if ($Contact1) $CompanyBlock.= "$Contact1";
if ($Title1) $CompanyBlock.= ", $Title1"; $CompanyBlock.= "\n";
if ($Phone) $CompanyBlock.= "Tel: $Phone\n".
if ($Fax) $CompanyBlock.= "Fax: $Fax\n".
if ($Email1) $CompanyBlock.= "Email: $Email1\n".
if ($ProductService)
$CompanyBlock.= "Products/Services: $ProductService\n".

$CompanyBlock.= "Objectives: ";

The result? The file returns with no execution, not even of code before
the problem, and with no error message, not so much as a notice. It took
me a good while to narrow it down and spot the problem (there's quite a
bit of code before this in the file). I knew the file was being called,
but even an echo statement at the very beginning produced no output. The
execution of the main script was not affected.

I thought this might save someone else a bit of time if they happen to
have the same problem.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Nov 6 '05 #1
8 1435
Alan Little wrote:
I started with the following code in an included file:

$CompanyBlock =
"$Company (Booth#: $Booth)\n".
"$Address\n".
"$City, $State $PostalCode\n".
"$Website\n".
"$Contact1, $Title1\n".
"Tel: $Phone\n".
"Fax: $Fax\n".
"Email: $Email1\n".
"Products/Services: $ProductService\n".
"Objectives: ";

I wanted to make some of the items conditional, but in so doing, I forgot
to change some of the . to ; and ended up with:

$CompanyBlock = $Company;
if ($Booth) $CompanyBlock.= " (Booth#: $Booth)";

$CompanyBlock.=
"\n".
"$Address\n".
"$City, $State $PostalCode\n";

if ($Website) $CompanyBlock.= "$Website\n";
if ($Contact1) $CompanyBlock.= "$Contact1";
if ($Title1) $CompanyBlock.= ", $Title1"; $CompanyBlock.= "\n";
if ($Phone) $CompanyBlock.= "Tel: $Phone\n".
if ($Fax) $CompanyBlock.= "Fax: $Fax\n".
if ($Email1) $CompanyBlock.= "Email: $Email1\n".
if ($ProductService)
$CompanyBlock.= "Products/Services: $ProductService\n".

$CompanyBlock.= "Objectives: ";

The result? The file returns with no execution, not even of code before
the problem, and with no error message, not so much as a notice. It took
me a good while to narrow it down and spot the problem (there's quite a
bit of code before this in the file). I knew the file was being called,
but even an echo statement at the very beginning produced no output. The
execution of the main script was not affected.

I thought this might save someone else a bit of time if they happen to
have the same problem.

Sorry, I think you code in a weird way..
What do you expect from if($varname) ?
Does your script rely on registerglobals = on?

Of course I cannot see the rest of your setup, so maybe I am talking bull.
;-)

Regards,
Erwin Moller
Nov 7 '05 #2
Carved in mystic runes upon the very living rock, the last words of
Erwin Moller of comp.lang.php make plain:
The result? The file returns with no execution, not even of code
before the problem, and with no error message, not so much as a
notice. It took me a good while to narrow it down and spot the
problem (there's quite a bit of code before this in the file). I knew
the file was being called, but even an echo statement at the very
beginning produced no output. The execution of the main script was
not affected.

I thought this might save someone else a bit of time if they happen
to have the same problem.
Sorry, I think you code in a weird way..


Perhaps, but it has no bearing on the issue. That is, if I used isset()
instead, perhaps it wouldn't tickle this particular bug, but it is in
fact a bug. Which reminds me, I should report it.
What do you expect from if($varname) ?


I expect PHP to tell me if it has a problem. While if ($var) may not be
ideal coding practice, it is legal.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Nov 26 '05 #3
If you checked the php error log it would have printed out something
like:

[27-Nov-2005 16:04:12] PHP Parse error: syntax error, unexpected T_IF
in etc......

i.e.

if ($Phone) $CompanyBlock.= "Tel: $Phone\n".
if ($Fax) $CompanyBlock.= "Fax: $Fax\n".
if ($Email1) $CompanyBlock.= "Email: $Email1\n".

Take this section of code, your concatenating IF statements like
strings so of course it's not going to work.

You should start by going to http://www.php.net/manual/en/

Nov 27 '05 #4

Alan Little wrote:

Perhaps, but it has no bearing on the issue. That is, if I used isset()
instead, perhaps it wouldn't tickle this particular bug, but it is in
fact a bug. Which reminds me, I should report it.
It's not a bug, it's illegal code. You can't terminate a line with a
dot, and you can't concatenate an if statement into a string. It
produces a parse error and stops execution. If you don't get an error
message it is because of your settings. It is still an error, though.
What do you expect from if($varname) ?


I expect PHP to tell me if it has a problem. While if ($var) may not be
ideal coding practice, it is legal.


Legal, yes. Useful in this situation, no. What you are saying in effect
is "if the website name can be converted to a non-zero number, then..."

I don't mean to give offence, but you should consider coding like other
people do, at least until you understand the consequences of not doing
so.

Ian

Nov 28 '05 #5
Carved in mystic runes upon the very living rock, the last words of Ian
B of comp.lang.php make plain:
Alan Little wrote:

Perhaps, but it has no bearing on the issue. That is, if I used
isset() instead, perhaps it wouldn't tickle this particular bug, but
it is in fact a bug. Which reminds me, I should report it.
It's not a bug, it's illegal code. You can't terminate a line with a
dot,


Sure you can, unless you mean you can't terminate a statement with a
dot. Nothing wrong with terminating a line with a dot, if your intention
to to concatenate whatever's on the next line.
and you can't concatenate an if statement into a string.
Of course. As mentioned originally, I inserted the if's, and forgot the
change the appropriate dots to semicolons.
It produces a parse error and stops execution.
It does neither. No error, and execution resumes in the main code (this
was in an included file).
If you don't get an error message it is because of your settings.
error_reporting = E_ALL
> What do you expect from if($varname) ?


I expect PHP to tell me if it has a problem. While if ($var) may not
be ideal coding practice, it is legal.


Legal, yes. Useful in this situation, no. What you are saying in
effect is "if the website name can be converted to a non-zero number,
then..."


I understand. And it is useful in this situation. It basically is a
shortcut of if(strlen(trim($Website)))
I don't mean to give offence,
None taken.
you should consider coding like other people do, at least until
you understand the consequences of not doing so.


Well, I do understand exactly what the code is doing, but to be honest I
don't believe I've heard all the arguments against using it; I just know
there are some.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Nov 28 '05 #6
Carved in mystic runes upon the very living rock, the last words of Sean
of comp.lang.php make plain:
If you checked the php error log it would have printed out something
like:

[27-Nov-2005 16:04:12] PHP Parse error: syntax error, unexpected T_IF
in etc......
Assuming error logging is on, which it isn't in this case, but error
reporting is, and there was no error.
if ($Phone) $CompanyBlock.= "Tel: $Phone\n".
if ($Fax) $CompanyBlock.= "Fax: $Fax\n".
if ($Email1) $CompanyBlock.= "Email: $Email1\n".

Take this section of code, your concatenating IF statements like
strings so of course it's not going to work.
I understand that. As stated in my original post, the code was initially
a single block of concatenation; I added the if's, and forgot to change
the appropriate dots to semicolons.
You should start by going to http://www.php.net/manual/en/


Gosh, a whole new world of enlightenment I hadn't seen before!

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Nov 28 '05 #7
Its display_errors in the php.ini which needs to be turned on that
displays errors as part of the output.

Nov 28 '05 #8
Carved in mystic runes upon the very living rock, the last words of Sean of
comp.lang.php make plain:
Its display_errors in the php.ini which needs to be turned on that
displays errors as part of the output.


Ah yes, that's turned off. It's still odd that it would continue execution
of the main code though, with a parse error in the included file. Even with
display_errors off, that is not the normal behavior.

Oh well.

--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Nov 28 '05 #9

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

Similar topics

3
by: redneck_kiwi | last post by:
Hi all: I have a really weird problem. I am developing a customer catalog system for my company and as such have delved into sessions for authentication and access levels. So far, I have managed...
0
by: newgene | last post by:
Hi, group, A weird clipboard behavior for your help: ==============Code============== from Tkinter import * import tkMessageBox root=Tk() root.withdraw() root.clipboard_clear()
5
by: python newbie | last post by:
hey, okay, I'm trying to figure out why my books: Quick Python, Python in a Nutshell, Python Cookbook and Learning Python don't say anything about the weird behavior of a list when you have one as...
3
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click...
0
by: Shaul Feldman | last post by:
Hello, I have a couple of things: 1) a page contains a button that has some JS code attached to it programmatically. Also the page loads a web user control with LoadControl method. In UC I...
8
by: XYZ | last post by:
I need to pass the address of a variableto some win32 API functions like RTLMoveMemory I noticed some weird behavior when pinning objects and using the handle's pointer to write data to the...
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
8
by: elias.farah | last post by:
Hello Everyone, I'm having some very weird behavior on a couple of Access forms. (Not all forms, just some of them). The forms have been working for years, under Access XP/2003 etc, and last...
1
by: =?Utf-8?B?TU5C?= | last post by:
Hi there! We are near the ending stage of an ASP.NET + IIS project, and started doing stress testing on the servers. We find ourselves with a very strange behavior, that can’t figure out since...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.