Apache / PHP parsers comments

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache / PHP parsers comments

Postby Laholm86 » 03. December 2017 17:21

I have used the following code for a long time. Probably I wrote it as I developed on a Linux computer. Since one and half year I'm using the code with a couple of adjustments on a Windows 10 with PHP 7.

Code: Select all
for($i=0; $i<$cnt; $i++){
   $rw=mysqli_fetch_array($rs, MYSQL_ASSOC);
   // $ctgid=$rw['CtgId'];
   $s='<div ...


A couple of days ago I received an error

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\... on line 952

The peculiar is that row 952 is the row that is commented. I have thought about the possibility that the error actually is on another row for, instance because of the comment signs. I have tested without the comment signs, but receives the same message and row number. I have also tried to move the row one step upwards in order to see that actually this row is the one causing the error, and the got the error on row 951, so I can only conclude that PHP or Apache is parsing the commented row. I have used commenting to disable code since more that ten years and have never experienced this before. The version displayed on XAMPP control panel is 3.2.2, but I guess this is not the XAMPP version it self. The XAMPP version should be 5.6.15 or 5.6.21 and l'm not aware of any auto updates, if there is such a thing for XAMPP.

Hope anyone has an idea
Laholm86
 
Posts: 5
Joined: 03. December 2017 15:32
XAMPP version: 3.2.2/5.6.15
Operating System: Windows 10

Re: Apache / PHP parsers comments

Postby Laholm86 » 05. December 2017 13:33

I also tested to frame the row within /**/, but the error still remains. One possible cause might be that I first used Kedit (or whatever the name is in Linux), then Notepad++ and then recently switched to Eclipse. Also the fact that I make correction working on Windows instead of Linux might be the cause, but as I already wrote, I have done this for more than one year without these problem. When I view End Of Line in Notepad, I can see LF in different colors, green for Windows LF and grey for Linux LF, or is there another explanation for the colors. With Notepad++ I also viewed All Characters but didn't see any foreign character.
Last edited by Laholm86 on 05. December 2017 13:51, edited 1 time in total.
Laholm86
 
Posts: 5
Joined: 03. December 2017 15:32
XAMPP version: 3.2.2/5.6.15
Operating System: Windows 10

Re: Apache / PHP parsers comments

Postby Nobbie » 05. December 2017 13:47

I dont think the commented line is the error, the error is probably above that line (an unbalanced quote, unbalanced brackets or whatever). Delete that commented line, what happens then?
Nobbie
 
Posts: 9800
Joined: 09. March 2008 13:04

Re: Apache / PHP parsers comments

Postby Laholm86 » 05. December 2017 14:21

Then, as the row is gone, so is the error. Now I got the error
Parse error: syntax error, unexpected 'ctg' (T_STRING) in C:\opt\xampp\htdocs\xxx on line 954. Line 954 is
Code: Select all
$s='<div id="ctg"><a href="javascript:xxx(' . $rw['CtgId'] . ')">' . $rw['Hdr'] . '</a></div>';

So I thought that the combination or use of ' and " suddenly became be a problem. I switched to the following code
Code: Select all
$dbl=chr(34);
$s='<div id=' . $dbl . 'ctg' . $dbl . '><a href=' . $dbl . 'javascript:xxx(' . $rw['CtgId'] . ')' . $dbl . '>' . $rw['Hdr'] . '</a></div>';

and now receives the error
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\opt\xampp\htdocs\xxx on line 954
But before I came to this, I just commented the original row, thus this is the row 954

Code: Select all
//            $s='<div id="ctg"><a href="javascript:xxx(' . $rw['CtgId'] . ')">' . $rw['Hdr'] . '</a></div>';


receives the message
Parse error: syntax error, unexpected 'ctg' (T_STRING) in C:\opt\xampp\htdocs\xxx on line 954

Thus, once again, the commented row is parsed.

'ctg' is in a CSS file, so maybe the file isn't found, but shouldn't I get another message if this was the case. And even if the file isn't found, I still think that the commented row is parsed.
Laholm86
 
Posts: 5
Joined: 03. December 2017 15:32
XAMPP version: 3.2.2/5.6.15
Operating System: Windows 10

Re: Apache / PHP parsers comments

Postby Nobbie » 05. December 2017 22:05

Laholm86 wrote:Then, as the row is gone, so is the error. Now I got the error
Parse error: syntax error, unexpected 'ctg' (T_STRING) in C:\opt\xampp\htdocs\xxx on line 954.


What means, that my idea is totally right, there is an error above. Kind of missing quote, missing bracket, missing semicolon, or whatever. Of course the parser try to fill up the incomplete statement and finally it surrenders on line 954 (or whereever). This is standard behaviour in case of syntax error.

You are wasting time and ressources if you still believe, that the commented statement is parsed. It is not. Believe me or not, its on you. i KNOW that there is a syntax error above. 100%.
Nobbie
 
Posts: 9800
Joined: 09. March 2008 13:04

Re: Apache / PHP parsers comments

Postby Laholm86 » 05. December 2017 22:42

In my opening entry I had the code (I add the row numbers)
Code: Select all
950 for($i=0; $i<$cnt; $i++){
951    $rw=mysqli_fetch_array($rs, MYSQL_ASSOC);
952   // $ctgid=$rw['CtgId'];
953   $s='<div ...


If the error is in the row above the reported, it is in the row 951. Like I wrote, I moved row 952 one step upwards so that it looked like this
Code: Select all
950 for($i=0; $i<$cnt; $i++){
951   // $ctgid=$rw['CtgId'];
952    $rw=mysqli_fetch_array($rs, MYSQL_ASSOC);
953   $s='<div ...


Now I got the message that the error was in row 951. Thus, if the error is on the row above the reported one, then the error moved from row 951 $rw=mysqli_fetch_array($rs, MYSQL_ASSOC); in the first try to row 950 for($i=0; $i<$cnt; $i++){
There is no quote in the two rows above and I also can't see any unbalanced brackets.
Laholm86
 
Posts: 5
Joined: 03. December 2017 15:32
XAMPP version: 3.2.2/5.6.15
Operating System: Windows 10

Re: Apache / PHP parsers comments

Postby Nobbie » 05. December 2017 23:02

As you said, if you delete the commented line, there is still an error. Exactly what i expected. Its on you to find the error, i cannot help you on that. Good luck, nothing left to say.
Nobbie
 
Posts: 9800
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 76 guests