FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » syntax error or notepad++ error?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
syntax error or notepad++ error? [message #182811] Mon, 16 September 2013 13:20 Go to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
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.'&amp;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.
Re: syntax error or notepad++ error? [message #182813 is a reply to message #182811] Mon, 16 September 2013 14:10 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 16 Sep 2013 09:20:03 -0400, richard wrote:

> So where's the syntax issue at?

Possibly in the code you haven't shown us.

> I made sure all tags matched properly before including the code.

Is this div contained within an inline element? eg a span?

Is notepad just confused?

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: syntax error or notepad++ error? [message #182814 is a reply to message #182811] Mon, 16 September 2013 14:11 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 16 Sep 2013 09:20:03 -0400, richard wrote:

> So where's the syntax issue at?

What happens when you feed the resulting output into the validator?

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: syntax error or notepad++ error? [message #182815 is a reply to message #182811] Mon, 16 September 2013 14:12 Go to previous messageGo to next message
Paul Herber is currently offline  Paul Herber
Messages: 26
Registered: February 2011
Karma: 0
Junior Member
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.'&amp;nid='.$number.'">';

You have single quotes in the URL that are closing the cho statement.



--
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/ twitter: @sandrilaLtd
Re: syntax error or notepad++ error? [message #182816 is a reply to message #182815] Mon, 16 September 2013 14:50 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Mon, 16 Sep 2013 15:12:44 +0100, 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.'&amp;nid='.$number.'">';
>
> You have single quotes in the URL that are closing the cho statement.

I removed the ? and everything after, it still won't pair up properly.
I reversed the single and dounle quotes, no change.
used the \" method, no change.
Re: syntax error or notepad++ error? [message #182817 is a reply to message #182815] Mon, 16 September 2013 15:05 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
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.'&amp;nid='.$number.'">';
>
> You have single quotes in the URL that are closing the cho statement.
>
>
>

Which is perfectly valid...

--
==================
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 #182818 is a reply to message #182811] Mon, 16 September 2013 15:12 Go to previous messageGo to next message
Jerry Stuckle is currently offline  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.'&amp;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 #182819 is a reply to message #182811] Mon, 16 September 2013 15:13 Go to previous messageGo to next message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma: 0
Senior Member
On Mon, 16 Sep 2013 09:20:03 -0400, 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.'&amp;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.

followup

apparently, notepad++ doesn't like tags in echo.

echo "<div>" is not ok.
while echo "div" is.
otherwise, the code by itself is kosher.

so I guess I'm gonna have to use the &amp version for the tag brackets.
Re: syntax error or notepad++ error? [message #182820 is a reply to message #182819] Mon, 16 September 2013 15:35 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
richard wrote:

> so I guess I'm gonna have to use the &amp 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;?>&amp;nid='<?php echo $number;?>">
<?php echo $vid[0];?>
</a>
<br />
<?php echo $vid[1];?>
<br />
<?php echo $vid[3];?>
</div>

--
Christoph M. Becker
Re: syntax error or notepad++ error? [message #182821 is a reply to message #182815] Mon, 16 September 2013 15:52 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  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.'&amp;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 Go to previous messageGo to next message
Paul Herber is currently offline  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.'&amp;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 Go to previous messageGo to next message
richard is currently offline  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.'&amp;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 Go to previous messageGo to next message
Jerry Stuckle is currently offline  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.'&amp;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 Go to previous messageGo to next message
Jerry Stuckle is currently offline  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 &amp 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;?>&amp;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 Go to previous messageGo to next message
J.O. Aho is currently offline  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.'&amp;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}&amp;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 Go to previous messageGo to next message
Norman Peelman is currently offline  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 &amp 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;?>&amp;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 Go to previous message
Thomas 'PointedEars'  is currently offline  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 &amp 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;?>&amp;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).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: problem with many buttons
Next Topic: Browser fingerprinting?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 13:51:57 GMT 2024

Total time taken to generate the page: 0.02872 seconds