|
|
|
|
|
|
Re: syntax error or notepad++ error? [message #182818 is a reply to message #182811] |
Mon, 16 September 2013 15:12 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2013 9:20 AM, richard wrote:
> All is well with matching divisions in notepad++ until I enter this code:
>
> echo "<div class='bcol2'>";
> echo "* ".$number." *<br />";
> echo '<a
> href="http://mroldies.net/index2.php?year='.$year.'&nid='.$number.'">';
> echo $vid[0];
> echo "</a>";
> echo "<br />";
> echo $vid[1];
> echo "<br />";
> echo $vid[3];
> echo" </div>\n";
>
> $number++;
>
> Notepad++ matches the opening division with the very last closing division
> tag.
> Not the closing tag it is supposed to pair with.
> Without this code, the pairs match.
>
> So where's the syntax issue at?
>
> I made sure all tags matched properly before including the code.
>
There's a limit as to how much editors can interpret the code. For
instance, they can't properly parse something like:
<?php if ($i == 3)
echo "<div class='foo'\n";
?>
because $i is only meaningful during the execution of the page.
They also don't handle things like:
echo "<";
echo "div ";
echo "class='foo'";
echo ">\n";
Even though this generates perfectly valid HTML (I know you wouldn't
write it like this, but it's an example).
As a result, when you mix things like regular html and html generated by
php (or any other language), editors are bound to get confused at some
point in time. It's just a limit of what editors can do.
The best way is to run the generated page through the HTML validator, as
Denis suggested.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
|
|
Re: syntax error or notepad++ error? [message #182821 is a reply to message #182815] |
Mon, 16 September 2013 15:52 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
Paul Herber wrote:
> On Mon, 16 Sep 2013 09:20:03 -0400, richard <noreply(at)example(dot)com> wrote:
>> All is well with matching divisions in notepad++ until I enter this code:
>>
>> echo "<div class='bcol2'>";
>> echo "* ".$number." *<br />";
>> echo '<a
^------------------------------------------------------------------
>> href="http://mroldies.net/index2.php?year='.$year.'&nid='.
--------------------------------------------^ ^---------^
>> $number.'">';
^--^
>
> You have single quotes in the URL that are closing the cho statement.
Nonsense.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
|
|
|
Re: syntax error or notepad++ error? [message #182822 is a reply to message #182817] |
Mon, 16 September 2013 16:52 |
Paul Herber
Messages: 26 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
On Mon, 16 Sep 2013 11:05:19 -0400, Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
> On 9/16/2013 10:12 AM, Paul Herber wrote:
>> On Mon, 16 Sep 2013 09:20:03 -0400, richard <noreply(at)example(dot)com> wrote:
>>
>>> All is well with matching divisions in notepad++ until I enter this code:
>>>
>>> echo "<div class='bcol2'>";
>>> echo "* ".$number." *<br />";
>>> echo '<a
>>> href="http://mroldies.net/index2.php?year='.$year.'&nid='.$number.'">';
>>
>> You have single quotes in the URL that are closing the cho statement.
>>
>>
>>
>
> Which is perfectly valid...
Oops, my mistook, I didn't notice the . concatenating the strings!
--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ twitter: @sandrilaLtd
|
|
|
Re: syntax error or notepad++ error? [message #182823 is a reply to message #182818] |
Mon, 16 September 2013 17:14 |
|
richard
Messages: 213 Registered: June 2013
Karma: 0
|
Senior Member |
|
|
On Mon, 16 Sep 2013 11:12:22 -0400, Jerry Stuckle wrote:
> On 9/16/2013 9:20 AM, richard wrote:
>> All is well with matching divisions in notepad++ until I enter this code:
>>
>> echo "<div class='bcol2'>";
>> echo "* ".$number." *<br />";
>> echo '<a
>> href="http://mroldies.net/index2.php?year='.$year.'&nid='.$number.'">';
>> echo $vid[0];
>> echo "</a>";
>> echo "<br />";
>> echo $vid[1];
>> echo "<br />";
>> echo $vid[3];
>> echo" </div>\n";
>>
>> $number++;
>>
>> Notepad++ matches the opening division with the very last closing division
>> tag.
>> Not the closing tag it is supposed to pair with.
>> Without this code, the pairs match.
>>
>> So where's the syntax issue at?
>>
>> I made sure all tags matched properly before including the code.
>>
>
> There's a limit as to how much editors can interpret the code. For
> instance, they can't properly parse something like:
>
> <?php if ($i == 3)
> echo "<div class='foo'\n";
> ?>
>
> because $i is only meaningful during the execution of the page.
>
> They also don't handle things like:
>
> echo "<";
> echo "div ";
> echo "class='foo'";
> echo ">\n";
>
> Even though this generates perfectly valid HTML (I know you wouldn't
> write it like this, but it's an example).
>
Actually, notepad++ does accept all you listed except the < and > signs.
> As a result, when you mix things like regular html and html generated by
> php (or any other language), editors are bound to get confused at some
> point in time. It's just a limit of what editors can do.
>
> The best way is to run the generated page through the HTML validator, as
> Denis suggested.
I did and it did not find anyhting out of whack.
|
|
|
Re: syntax error or notepad++ error? [message #182824 is a reply to message #182823] |
Mon, 16 September 2013 17:47 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2013 1:14 PM, richard wrote:
> On Mon, 16 Sep 2013 11:12:22 -0400, Jerry Stuckle wrote:
>
>> On 9/16/2013 9:20 AM, richard wrote:
>>> All is well with matching divisions in notepad++ until I enter this code:
>>>
>>> echo "<div class='bcol2'>";
>>> echo "* ".$number." *<br />";
>>> echo '<a
>>> href="http://mroldies.net/index2.php?year='.$year.'&nid='.$number.'">';
>>> echo $vid[0];
>>> echo "</a>";
>>> echo "<br />";
>>> echo $vid[1];
>>> echo "<br />";
>>> echo $vid[3];
>>> echo" </div>\n";
>>>
>>> $number++;
>>>
>>> Notepad++ matches the opening division with the very last closing division
>>> tag.
>>> Not the closing tag it is supposed to pair with.
>>> Without this code, the pairs match.
>>>
>>> So where's the syntax issue at?
>>>
>>> I made sure all tags matched properly before including the code.
>>>
>>
>> There's a limit as to how much editors can interpret the code. For
>> instance, they can't properly parse something like:
>>
>> <?php if ($i == 3)
>> echo "<div class='foo'\n";
>> ?>
>>
>> because $i is only meaningful during the execution of the page.
>>
>> They also don't handle things like:
>>
>> echo "<";
>> echo "div ";
>> echo "class='foo'";
>> echo ">\n";
>>
>> Even though this generates perfectly valid HTML (I know you wouldn't
>> write it like this, but it's an example).
>>
>
> Actually, notepad++ does accept all you listed except the < and > signs.
>
Sure, it will *ACCEPT* it - but it will not *PROCESS* it properly.
>
>> As a result, when you mix things like regular html and html generated by
>> php (or any other language), editors are bound to get confused at some
>> point in time. It's just a limit of what editors can do.
>>
>> The best way is to run the generated page through the HTML validator, as
>> Denis suggested.
>
> I did and it did not find anyhting out of whack.
>
Then your code is fine.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: syntax error or notepad++ error? [message #182825 is a reply to message #182820] |
Mon, 16 September 2013 17:48 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 9/16/2013 11:35 AM, Christoph Michael Becker wrote:
> richard wrote:
>
>> so I guess I'm gonna have to use the & version for the tag brackets.
>
> You may consider using PHP's "template" syntax instead:
>
> <div class="bcol2">
> * <?php echo $number;?> *<br />
> <a href="http://mroldies.net/index2.php?year='<?php echo
> $year;?>&nid='<?php echo $number;?>">
> <?php echo $vid[0];?>
> </a>
> <br />
> <?php echo $vid[1];?>
> <br />
> <?php echo $vid[3];?>
> </div>
>
What a mess!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: syntax error or notepad++ error? [message #182826 is a reply to message #182811] |
Mon, 16 September 2013 18:40 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 16/09/13 15:20, richard wrote:
> All is well with matching divisions in notepad++ until I enter this code:
>
> echo "<div class='bcol2'>";
> echo "* ".$number." *<br />";
> echo '<a
> href="http://mroldies.net/index2.php?year='.$year.'&nid='.$number.'">';
> echo $vid[0];
> echo "</a>";
> echo "<br />";
> echo $vid[1];
> echo "<br />";
> echo $vid[3];
> echo" </div>\n";
Gosh, this is really unreadable code, I think you should make it more
readable , it's far easier to see HTML errors if you don't use that many
echo's.
tried:
$output = <<< EOF
<div class='bcol2'>
* {$nbumber} *<br />
<a
href='http://mroldies.net/index2.php?year={$year}&nid={$number}'>{$vid[0]}</a>
<br />
{$vid[1]}
<br />
{$vid[3]}
</div>
EOF;
sure your notepad++ would become a lot happier too.
To make a good code, you separate PHP functions and HTML generation as
much as possible, you don't need to echo, just end the PHP parsing with
a endtag and start it again with a starttag when you need, that is less
stressing for the system than using echo.
--
//Aho
|
|
|
Re: syntax error or notepad++ error? [message #182827 is a reply to message #182820] |
Tue, 17 September 2013 01:49 |
Norman Peelman
Messages: 126 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 09/16/2013 11:35 AM, Christoph Michael Becker wrote:
> richard wrote:
>
>> so I guess I'm gonna have to use the & version for the tag brackets.
>
> You may consider using PHP's "template" syntax instead:
>
> <div class="bcol2">
> * <?php echo $number;?> *<br />
> <a href="http://mroldies.net/index2.php?year='<?php echo
> $year;?>&nid='<?php echo $number;?>">
> <?php echo $vid[0];?>
> </a>
> <br />
> <?php echo $vid[1];?>
> <br />
> <?php echo $vid[3];?>
> </div>
>
My eyes! My eyes! Please - someone stop the pain!!!!
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
|
|
|
Re: syntax error or notepad++ error? [message #182828 is a reply to message #182827] |
Tue, 17 September 2013 16:48 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
Norman Peelman wrote:
> On 09/16/2013 11:35 AM, Christoph Michael Becker wrote:
>> richard wrote:
>>> so I guess I'm gonna have to use the & version for the tag brackets.
>>
>> You may consider using PHP's "template" syntax instead:
>>
>> <div class="bcol2">
>> * <?php echo $number;?> *<br />
>> <a href="http://mroldies.net/index2.php?year='<?php echo
>> $year;?>&nid='<?php echo $number;?>">
>> <?php echo $vid[0];?>
>> </a>
>> <br />
>> <?php echo $vid[1];?>
>> <br />
>> <?php echo $vid[3];?>
>> </div>
>
> My eyes! My eyes! Please - someone stop the pain!!!!
:)
Are you referring to the tag soup? If yes, to be fair, Christoph just
rewrote with “‘template’ syntax” what was in the OP.
PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
|
|
|