473,325 Members | 2,342 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,325 software developers and data experts.

Error reporting based on characters preceding php open tag

2
Hey everyone,
I am using .phtml files for templating, and I discovered that a php tag that is preceded with the combination of: any character, equals sign, either double or single quote, will result in odd error reporting behavior. Calling an incorrect function will terminating the script and will not display any error message in the browser. (Only for the condition described above. Otherwise it will report correctly.)

Try this code to duplicate the error: (Assuming error_reporting is set to E_ALL)

With href=" before <?php. The script terminates without displaying an error.
Expand|Select|Wrap|Line Numbers
  1. <p>one</p>
  2. <p><a href="<?php notAFunc('two') ?>"></a></p>
  3. <p>three</p>
  4.  
Now without the " before <?php. This script terminates and display the error.
Expand|Select|Wrap|Line Numbers
  1. <p>one</p>
  2. <p><a href=<?php notAFunc('two') ?>"></a></p>
  3. <p>three</p>
  4.  
I have this problem across my entire system, and I'm at least glad to know where the errors were mysteriously disappearing to. Does anyone know what the problem is? Thanks so much!
Mar 22 '10 #1
2 1610
Atli
5,058 Expert 4TB
Hey.

When this happens, does the PHP error show in the source of the document?

If the PHP error is printed into attribute quote-marks inside the HTML markup, the error -- or at least a part of it -- may be parsed as the value of that attribute, rather than output to be displayed.

For instance, if I do this:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ini_set('display_errors' ,true);
  3. error_reporting(E_ALL);
  4. ?>
  5. <a href="<?php idontexist(); ?>">Linkage!</a>
The first word of the error message, which happens to be a <br> tag, becomes the value of the href attribute. The rest of the message, however, breaks the HTML markup. It is injected into the <a> tag, where it doesn't belong, and leaves the HTML parser to either disregard it, or to try fix it.

The browsers handle this differently. IE decides to dissregard the <a> tag and display the error as text; Firefox compensates by closing the <a> tag when it detects the error and use the rest of it as the text for the link. Chrome just disregards the whole thing and displays nothing. (Chrome's behavior is probably the "best" out of the three. - Browsers should just display things as they are, not try to "guess" what to do with broken code.)
Mar 22 '10 #2
rprice
2
Thanks Atli,
No, this is not an html issue, it is not displaying in the source at all. Perhaps its a bug with the version of php running on my server, because your example does not work for me either, simply a blank html source.

I just experimented with it some more and the error will be output when if the code read something like this:

Expand|Select|Wrap|Line Numbers
  1. <p>one</p>
  2. <p>href="<?php notAFunc('two') ?></p>
  3. <p>three</p>
  4.  
But when you then put this inside the p tag, instead of after the p tag, it does not output. Like this:
Expand|Select|Wrap|Line Numbers
  1. <p>one</p>
  2. <p href="<?php notAFunc('two') ?></p>
  3. <p>three</p>
  4.  
So it seems that php is trying to help me by not displaying errors when within an html attribute. Is that possibly a feature?
Mar 22 '10 #3

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

Similar topics

11
by: muser | last post by:
In the code I supplied before this one, the cause of the problem is an access violation error. When I run the debugger it skips into what I can only assume is the compilers version of my code. And...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
4
by: Troy | last post by:
We recently installed the .Net framework on a windows 2000 server. Shortly after that we experienced intermitant problems running a web based program that accesses an Access 2002 database. The...
4
by: Philip | last post by:
I'm rather new to database stuff. I've been using postgresql for a couple years, but that doesn't mean I understand what I'm doing. I have simply followed the "HOW-TOs". But now I think I'm about...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
0
by: YellowfinTeam | last post by:
Yellowfin is proud to announce the release of 3.1. The major theme of this release is enhanced integration capability. We have introduced a range of new web services and authentication processes...
0
by: RCapps | last post by:
When running the below SQL Query I keep getting the following error: Server: Msg 4924, Level 16, State 1, Line 1 ALTER TABLE DROP COLUMN failed because column 'ContractDef' does not exist in table...
0
debasisdas
by: debasisdas | last post by:
REPORTING FUNCTIONS ALLOW THE EXECUTION OF VARIOUS AGGREGATE FUNCTIONS AGAINST A RESULT SET.UNLIKE WINDOWING FUNCTIONS THESE CAN'T SPECIFY LOCALISED WINDOWS AND THUS GENERATE THE SAME RESULT FOR EACH...
1
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.