Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #10498 > unrolled thread

Function Problem

Started byTwayne <nobody@spamcop.net>
First post2013-08-13 14:29 -0400
Last post2013-08-17 13:44 -0400
Articles 20 on this page of 21 — 9 participants

Back to article view | Back to comp.lang.php


Contents

  Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 14:29 -0400
    Re: Function Problem Paul Herber <paul@pherber.com> - 2013-08-13 21:57 +0100
      Re: Function Problem Jerry Stuckle <jstucklex@attglobal.net> - 2013-08-13 17:26 -0400
      Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 19:29 -0400
        Re: Function Problem The Natural Philosopher <tnp@invalid.invalid> - 2013-08-14 10:24 +0100
    Re: Function Problem Norman Peelman <npeelman@cfl.rr.com> - 2013-08-13 19:25 -0400
      Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 19:39 -0400
    Re: Function Problem David Robley <me@home.invalid> - 2013-08-14 09:04 +0930
      Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 20:45 -0400
      PS Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 20:51 -0400
    Re: Function Problem Richard Yates <richard@yatesguitar.com> - 2013-08-13 16:48 -0700
      Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-13 21:00 -0400
    Re: Function Problem "J.O. Aho" <user@example.net> - 2013-08-14 07:10 +0200
      Re: Function Problem Twayne <nobody@spamcop.net> - 2013-08-15 18:17 -0400
    Re: Function Problem RESOLVED Twayne <nobody@spamcop.net> - 2013-08-15 17:28 -0400
      Re: Function Problem RESOLVED Tim Streater <timstreater@greenbee.net> - 2013-08-15 23:15 +0100
        Re: Function Problem RESOLVED Twayne <nobody@spamcop.net> - 2013-08-15 18:59 -0400
          Re: Function Problem RESOLVED Tim Streater <timstreater@greenbee.net> - 2013-08-16 08:50 +0100
            Re: Function Problem RESOLVED Twayne <nobody@spamcop.net> - 2013-08-17 13:41 -0400
      Re: Function Problem RESOLVED Norman Peelman <npeelman@cfl.rr.com> - 2013-08-16 06:43 -0400
        Re: Function Problem RESOLVED Twayne <nobody@spamcop.net> - 2013-08-17 13:44 -0400

Page 1 of 2  [1] 2  Next page →


#10498 — Function Problem

FromTwayne <nobody@spamcop.net>
Date2013-08-13 14:29 -0400
SubjectFunction Problem
Message-ID<kudttm$82o$1@speranza.aioe.org>
Hi All,
    Seems like I'm getting to be a regular fixture here but ... I'm baaack!

Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:

I've created a Function that works on other pages  but after working for 
some time, no longer functions. I don't think the Function is the 
obvious problem; see below it for more details. The function is:

109  // FUNCTIONS USED: ------------------------------
110
111 function check_input($data)
112 {
  113   $data = trim($data);
114    $data = stripslashes($data);	
115    $data = htmlspecialchars($data);	
116    return $data;	
117  }
118  ?>
============== end function =========

That code resides at the end of the php page in question so there is 
normally nothing after it but a session_destroy() and a die(); Message 
has been e-mailed. The error message is:

----------- error message ----------------
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php 
on line 114
----------- end error message -----------

     BUT, moving the lines around and monitoring the line number the 
error is reported on seems to be PAST line 117 OR line 117, depending on 
(your guess is as good as mine).

I've removed the PHP End (?>) and of course that results in the expected 
error message. Deleting session_destroy and die had no effect on 
anything; error lines remained in the same places, different line 
numbers of course.

Realizing PHP's often misleading line numbers, I went through each and 
every use of the function call on the entire page.

I don't understand what the "unexpected $end" might be; I've looked and 
looked without sucess.  All I feel sure of at the moment is that it's 
not the function itself: I've used it and others on other pages and 
other forms and they all worked fine. I'm going to restudy my error log 
and see if I can find anything there but I don't think I will. I'm 
thinking it's actually a type somewhere but darned if I can find it!
    Hmm, wonder if it matters where the function is located within the 
file? I'll have to look into that more.

So ... if anyone has any ideas, leads, suggestions or comments on this 
matter I'd sincerely appreciate your input and will provide anything 
else I can should you have questions.
    I am not allowed to post full code, so the above is really all I can 
reveal in actual code.
    I don't think I'm a newbie, but at the same time I'm not overly 
experienced either; still a lot to learn!

Thanks in advance,

Twayne`









[toc] | [next] | [standalone]


#10499

FromPaul Herber <paul@pherber.com>
Date2013-08-13 21:57 +0100
Message-ID<ob7l09p0n832dobh7i6e6e5qldk0t45ne5@news.eternal-september.org>
In reply to#10498
On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody@spamcop.net> wrote:

>Hi All,
>    Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>
>Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>
>I've created a Function that works on other pages  but after working for 
>some time, no longer functions. I don't think the Function is the 
>obvious problem; see below it for more details. The function is:
>
>109  // FUNCTIONS USED: ------------------------------
>110
>111 function check_input($data)
>112 {
>  113   $data = trim($data);
>114    $data = stripslashes($data);	
>115    $data = htmlspecialchars($data);	
>116    return $data;	
>117  }
>118  ?>
>============== end function =========
>
>That code resides at the end of the php page in question so there is 
>normally nothing after it but a session_destroy() and a die(); Message 
>has been e-mailed. The error message is:

Functions like this would normally go at the beginning of the page.
Are you sure that PHP execution isn't falling through from lines above?



-- 
Regards, Paul Herber, Sandrila Ltd.
http://www.sandrila.co.uk/    twitter: @sandrilaLtd      

[toc] | [prev] | [next] | [standalone]


#10500

FromJerry Stuckle <jstucklex@attglobal.net>
Date2013-08-13 17:26 -0400
Message-ID<kue8ac$99e$1@dont-email.me>
In reply to#10499
On 8/13/2013 4:57 PM, Paul Herber wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody@spamcop.net> wrote:
>
>> Hi All,
>>     Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>>
>> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>>
>> I've created a Function that works on other pages  but after working for
>> some time, no longer functions. I don't think the Function is the
>> obvious problem; see below it for more details. The function is:
>>
>> 109  // FUNCTIONS USED: ------------------------------
>> 110
>> 111 function check_input($data)
>> 112 {
>>   113   $data = trim($data);
>> 114    $data = stripslashes($data);	
>> 115    $data = htmlspecialchars($data);	
>> 116    return $data;	
>> 117  }
>> 118  ?>
>> ============== end function =========
>>
>> That code resides at the end of the php page in question so there is
>> normally nothing after it but a session_destroy() and a die(); Message
>> has been e-mailed. The error message is:
>
> Functions like this would normally go at the beginning of the page.
> Are you sure that PHP execution isn't falling through from lines above?
>
>
>

Code will never "fall into" a function.  The code in the function will 
only be executed when the function is called.  However, you are correct 
in that most programmers put functions at the top of the page.  Maybe a 
leftover from early C, or maybe because people just want to get it out 
of the way :)

And Twayne doesn't want my help, so I'll stop here.


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#10502

FromTwayne <nobody@spamcop.net>
Date2013-08-13 19:29 -0400
Message-ID<kuefgp$n6b$1@speranza.aioe.org>
In reply to#10499
On 2013-08-13 4:57 PM, Paul Herber wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody@spamcop.net> wrote:
>
>> Hi All,

...

>>
>> 109  // FUNCTIONS USED: ------------------------------
>> 110
>> 111 function check_input($data)
>> 112 {
>>   113   $data = trim($data);
>> 114    $data = stripslashes($data);	
>> 115    $data = htmlspecialchars($data);	
>> 116    return $data;	
>> 117  }
>> 118  ?>
>> ============== end function =========
>>
>> That code resides at the end of the php page in question so there is
>> normally nothing after it but a session_destroy() and a die(); Message
>> has been e-mailed. The error message is:
>
> Functions like this would normally go at the beginning of the page.
> Are you sure that PHP execution isn't falling through from lines above?
>
>
>

Thanks, Paul, I've been playing with just that.
    First I chose a location where no use of the function had occurred 
yet. No change.
     Finally I moved it all the way to the top, and it started to work!! 
But my joy was short-lived as when I closed/restarted my browser to kill 
off all session counters etc., the error was back!
    Unfortunately I did two things at once: Moved similar code on the 
preceding page to the very top also (no white space of any kind) 
immediately after session_start. I ran the entire form over and that 
preceding page worked OK, but the original page I queried about, then 
gave me a familiar PHP message:
-----------
Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php 
on line 112
-----------

Different place in the text, not at the end, but it IS prior to ending 
PHP and starting HTML code!

I should probably tell anyone reading now to Stand Down;
  much as I hate to, I think I'll back up to an archived version that 
WAS working but without most of the validation rules and containing 
preset inputs to make the forms quicker to test.

My thanks to you and I'll be back when this is resolved to explain 
whatever I discover is the danged reason! <g>

Regards,

Twayne`










[toc] | [prev] | [next] | [standalone]


#10510

FromThe Natural Philosopher <tnp@invalid.invalid>
Date2013-08-14 10:24 +0100
Message-ID<kuficn$gub$2@news.albasani.net>
In reply to#10502
On 14/08/13 00:29, Twayne wrote:
>
> I should probably tell anyone reading now to Stand Down;
>  much as I hate to, I think I'll back up to an archived version that
> WAS working but without most of the validation rules and containing
> preset inputs to make the forms quicker to test.
>

There are classes of errors that are bastards, something like an
unclosed quote will throw errors miles away from where the actual error
is, as everything until the NEXT quote is 'just a string'
and compared with early assemblers and compilers, error reporting is
MUCH closer than it used to be to where the actual syntax error is.


> My thanks to you and I'll be back when this is resolved to explain
> whatever I discover is the danged reason! <g>
>
> Regards,
>
> Twayne`
>
>
>
>
>
>
>
>
>
>
>


-- 
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to lead are elected by the least capable of producing, and where the members of society least likely to sustain themselves or succeed, are rewarded with goods and services paid for by the confiscated wealth of a diminishing number of producers.

[toc] | [prev] | [next] | [standalone]


#10501

FromNorman Peelman <npeelman@cfl.rr.com>
Date2013-08-13 19:25 -0400
Message-ID<kuefa5$ggm$1@dont-email.me>
In reply to#10498
On 08/13/2013 02:29 PM, Twayne wrote:
> Hi All,
>     Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>
> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>
> I've created a Function that works on other pages  but after working for
> some time, no longer functions. I don't think the Function is the
> obvious problem; see below it for more details. The function is:
>
> 109  // FUNCTIONS USED: ------------------------------
> 110
> 111 function check_input($data)
> 112 {
> 113    $data = trim($data);
> 114    $data = stripslashes($data);
> 115    $data = htmlspecialchars($data);
> 116    return $data;
> 117  }
> 118  ?>
> ============== end function =========
>
> That code resides at the end of the php page in question so there is
> normally nothing after it but a session_destroy() and a die(); Message
> has been e-mailed. The error message is:
>
> ----------- error message ----------------
> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
> on line 114
> ----------- end error message -----------
>
>      BUT, moving the lines around and monitoring the line number the
> error is reported on seems to be PAST line 117 OR line 117, depending on
> (your guess is as good as mine).

   Moving what lines around? Is this script only or are you jumping in 
and out of PHP and HTML?

>
> I've removed the PHP End (?>) and of course that results in the expected
> error message. Deleting session_destroy and die had no effect on
> anything; error lines remained in the same places, different line
> numbers of course.
>
> Realizing PHP's often misleading line numbers, I went through each and
> every use of the function call on the entire page.
>
> I don't understand what the "unexpected $end" might be; I've looked and
> looked without sucess.  All I feel sure of at the moment is that it's
> not the function itself: I've used it and others on other pages and
> other forms and they all worked fine. I'm going to restudy my error log
> and see if I can find anything there but I don't think I will. I'm
> thinking it's actually a type somewhere but darned if I can find it!
>     Hmm, wonder if it matters where the function is located within the
> file? I'll have to look into that more.
>

   No, it should be fine,

> So ... if anyone has any ideas, leads, suggestions or comments on this
> matter I'd sincerely appreciate your input and will provide anything
> else I can should you have questions.
>     I am not allowed to post full code, so the above is really all I can
> reveal in actual code.
>     I don't think I'm a newbie, but at the same time I'm not overly
> experienced either; still a lot to learn!
>
> Thanks in advance,
>
> Twayne`
>

   The function as coded is fine, it's all there, nothing is missing. 
Therefor the error lies above it. check for unclosed () {} ""...


-- 
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-

[toc] | [prev] | [next] | [standalone]


#10504

FromTwayne <nobody@spamcop.net>
Date2013-08-13 19:39 -0400
Message-ID<kueg3m$oe7$1@speranza.aioe.org>
In reply to#10501
On 2013-08-13 7:25 PM, Norman Peelman wrote:
> On 08/13/2013 02:29 PM, Twayne wrote:
>> Hi All,
>>     Seems like I'm getting to be a regular fixture here but ... I'm
>> baaack!
>>
>> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>>
>> I've created a Function that works on other pages  but after working for
>> some time, no longer functions. I don't think the Function is the
>> obvious problem; see below it for more details. The function is:
>>
>> 109  // FUNCTIONS USED: ------------------------------
>> 110
>> 111 function check_input($data)
>> 112 {
>> 113    $data = trim($data);
>> 114    $data = stripslashes($data);
>> 115    $data = htmlspecialchars($data);
>> 116    return $data;
>> 117  }
>> 118  ?>
>> ============== end function =========
>>
>> That code resides at the end of the php page in question so there is
>> normally nothing after it but a session_destroy() and a die(); Message
>> has been e-mailed. The error message is:
>>
>> ----------- error message ----------------
>> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
>> on line 114
>> ----------- end error message -----------
>>
>>      BUT, moving the lines around and monitoring the line number the
>> error is reported on seems to be PAST line 117 OR line 117, depending on
>> (your guess is as good as mine).
>
>    Moving what lines around? Is this script only or are you jumping in
> and out of PHP and HTML?
>
>>
>> I've removed the PHP End (?>) and of course that results in the expected
>> error message. Deleting session_destroy and die had no effect on
>> anything; error lines remained in the same places, different line
>> numbers of course.
>>
>> Realizing PHP's often misleading line numbers, I went through each and
>> every use of the function call on the entire page.
>>
>> I don't understand what the "unexpected $end" might be; I've looked and
>> looked without sucess.  All I feel sure of at the moment is that it's
>> not the function itself: I've used it and others on other pages and
>> other forms and they all worked fine. I'm going to restudy my error log
>> and see if I can find anything there but I don't think I will. I'm
>> thinking it's actually a type somewhere but darned if I can find it!
>>     Hmm, wonder if it matters where the function is located within the
>> file? I'll have to look into that more.
>>
>
>    No, it should be fine,
>
>> So ... if anyone has any ideas, leads, suggestions or comments on this
>> matter I'd sincerely appreciate your input and will provide anything
>> else I can should you have questions.
>>     I am not allowed to post full code, so the above is really all I can
>> reveal in actual code.
>>     I don't think I'm a newbie, but at the same time I'm not overly
>> experienced either; still a lot to learn!
>>
>> Thanks in advance,
>>
>> Twayne`
>>
>
>    The function as coded is fine, it's all there, nothing is missing.
> Therefor the error lies above it. check for unclosed () {} ""...
>
>

Good thoughts, Norman. Never hurts to repeat things a time or two; I've 
decided I'll wait til tomorrow when my mind's a bit clearer though. 
Can't recall right now whether I checked for "" or [] or anything else 
that doesn't come to mind right now, so I'll definitely do that! If no 
luck I'll start going through everythng a line at a time and even back 
up to an archived version for a restart if I have to - I just hate to 
throw away so much work and start over again, but ... cookies crumble 
like that, I know<g>.

    I'll come back & let folks know what I found if/when I figure it out.

Regards,

Twayne`

[toc] | [prev] | [next] | [standalone]


#10503

FromDavid Robley <me@home.invalid>
Date2013-08-14 09:04 +0930
Message-ID<kuefof$r98$1@news.albasani.net>
In reply to#10498
Twayne wrote:

> Hi All,
>     Seems like I'm getting to be a regular fixture here but ... I'm
>     baaack!
> 
> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
> 
> I've created a Function that works on other pages  but after working for
> some time, no longer functions. I don't think the Function is the
> obvious problem; see below it for more details. The function is:
> 
> 109  // FUNCTIONS USED: ------------------------------
> 110
> 111 function check_input($data)
> 112 {
>   113   $data = trim($data);
> 114    $data = stripslashes($data);
> 115    $data = htmlspecialchars($data);
> 116    return $data;
> 117  }
> 118  ?>
> ============== end function =========
> 
> That code resides at the end of the php page in question so there is
> normally nothing after it but a session_destroy() and a die(); Message
> has been e-mailed. The error message is:
> 
> ----------- error message ----------------
> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
> on line 114
> ----------- end error message -----------
> 
>      BUT, moving the lines around and monitoring the line number the
> error is reported on seems to be PAST line 117 OR line 117, depending on
> (your guess is as good as mine).
> 
> I've removed the PHP End (?>) and of course that results in the expected
> error message. Deleting session_destroy and die had no effect on
> anything; error lines remained in the same places, different line
> numbers of course.
> 
> Realizing PHP's often misleading line numbers, I went through each and
> every use of the function call on the entire page.
> 
> I don't understand what the "unexpected $end" might be; I've looked and
> looked without sucess.  All I feel sure of at the moment is that it's
> not the function itself: I've used it and others on other pages and
> other forms and they all worked fine. I'm going to restudy my error log
> and see if I can find anything there but I don't think I will. I'm
> thinking it's actually a type somewhere but darned if I can find it!
>     Hmm, wonder if it matters where the function is located within the
> file? I'll have to look into that more.
> 
> So ... if anyone has any ideas, leads, suggestions or comments on this
> matter I'd sincerely appreciate your input and will provide anything
> else I can should you have questions.
>     I am not allowed to post full code, so the above is really all I can
> reveal in actual code.
>     I don't think I'm a newbie, but at the same time I'm not overly
> experienced either; still a lot to learn!
> 
> Thanks in advance,
> 
> Twayne`

https://www.google.com.au/search?q=Parse+error:+syntax+error,
+unexpected+%24end+in&ie=utf-8&oe=utf-8&rls=org.mozilla:en-
US:official&client=firefox-a&gws_rd=cr will give you the solution. This is 
quite a common error :-)

You probably don't want to use stripslashes unless you KNOW that your data 
will have extraneous slashes added by magic_quotes_* otherwise you may strip 
valid slashes. At least use get_magic_quotes_gpc to see if magic quotes are 
enabled, and only strip slashes if they are

-- 
Cheers
David Robley

"I will not steamroller that garbage," Tom flatly refused.

[toc] | [prev] | [next] | [standalone]


#10506

FromTwayne <nobody@spamcop.net>
Date2013-08-13 20:45 -0400
Message-ID<kuejv7$kg$1@speranza.aioe.org>
In reply to#10503
On 2013-08-13 7:34 PM, David Robley wrote:
> Twayne wrote:
>
>> Hi All,
>>      Seems like I'm getting to be a regular fixture here but ... I'm
>>      baaack!
>>
>> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>>
>> I've created a Function that works on other pages  but after working for
>> some time, no longer functions. I don't think the Function is the
>> obvious problem; see below it for more details. The function is:
>>
>> 109  // FUNCTIONS USED: ------------------------------
>> 110
>> 111 function check_input($data)
>> 112 {
>>    113   $data = trim($data);
>> 114    $data = stripslashes($data);
>> 115    $data = htmlspecialchars($data);
>> 116    return $data;
>> 117  }
>> 118  ?>
>> ============== end function =========
>>
>> That code resides at the end of the php page in question so there is
>> normally nothing after it but a session_destroy() and a die(); Message
>> has been e-mailed. The error message is:
>>
>> ----------- error message ----------------
>> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
>> on line 114
>> ----------- end error message -----------
>>

...

>>      I am not allowed to post full code, so the above is really all I can
>> reveal in actual code.
>>      I don't think I'm a newbie, but at the same time I'm not overly
>> experienced either; still a lot to learn!
>>
>> Thanks in advance,
>>
>> Twayne`
>
> https://www.google.com.au/search?q=Parse+error:+syntax+error,
> +unexpected+%24end+in&ie=utf-8&oe=utf-8&rls=org.mozilla:en-
> US:official&client=firefox-a&gws_rd=cr will give you the solution. This is
> quite a common error :-)
>
> You probably don't want to use stripslashes unless you KNOW that your data
> will have extraneous slashes added by magic_quotes_* otherwise you may strip
> valid slashes. At least use get_magic_quotes_gpc to see if magic quotes are
> enabled, and only strip slashes if they are
>
Many thanks! I never thought about searching for the error message 
itself; it never got me much when I tried, but that was some time ago! 
That link contains a cornucopia of good information!

Haven't put its ideas to work yet; too late in the day. But tomorrow 
promises to be a better day now.

Regards,

Twayne`




[toc] | [prev] | [next] | [standalone]


#10507 — PS Re: Function Problem

FromTwayne <nobody@spamcop.net>
Date2013-08-13 20:51 -0400
SubjectPS Re: Function Problem
Message-ID<kuekb6$1cm$1@speranza.aioe.org>
In reply to#10503
PS - may I inquire where in AU your are? Assuming you ARE in Australia? 
  Spent a lot of time there at Garbutt (near Townsville, QLD) back in 
the '60's, on detachments from the US Naval Air Force & am just trying 
to find any "locals" that might be left who want to dialog with a US 
Citizen. Nothing untoward intended, NOT looking for women of reputation <g>.

Twayne`

[toc] | [prev] | [next] | [standalone]


#10505

FromRichard Yates <richard@yatesguitar.com>
Date2013-08-13 16:48 -0700
Message-ID<o8hl09t1q6evcdv3d6a05fgaf814alkctl@4ax.com>
In reply to#10498
On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody@spamcop.net> wrote:

>Hi All,
>    Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>

>----------- error message ----------------
>Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php 
>on line 114
>----------- end error message -----------

In my experience, 'unexpected $end' is nearly always caused by an
unclosed '{' somewhere in the whole script. Your function is not the
culprit. 

Find the unclosed '{'. This is really basic stuff, Twayne, even for a
realtive novice like me. 

[toc] | [prev] | [next] | [standalone]


#10508

FromTwayne <nobody@spamcop.net>
Date2013-08-13 21:00 -0400
Message-ID<kueks3$2gq$1@speranza.aioe.org>
In reply to#10505
On 2013-08-13 7:48 PM, Richard Yates wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody@spamcop.net> wrote:
> b
>> Hi All,
>>     Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>>
>
>> ----------- error message ----------------
>> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
>> on line 114
>> ----------- end error message -----------
>
> In my experience, 'unexpected $end' is nearly always caused by an
> unclosed '{' somewhere in the whole script. Your function is not the
> culprit.

Agreed.

>
> Find the unclosed '{'. This is really basic stuff, Twayne, even for a
> realtive novice like me.
>

Hi Richard,

Agreed it should be really basic stuff but I've covered of the pairing 
of [], (), {}, "" and other things and it isn't getting me anywhere. My 
editor, NoteTab, will check for unclosed brackets & several other 
things; nothing showing up yet. I did find a misplaced ";" but it 
changed nothing since it was in a validation routine and not being used 
and not showing as an error for whatever reason.

Sometimes the obvious isn't that obvious; that's why I asked for 
comments, etc. in my original query.

Twayne`

[toc] | [prev] | [next] | [standalone]


#10509

From"J.O. Aho" <user@example.net>
Date2013-08-14 07:10 +0200
Message-ID<b70hr1Fak9fU1@mid.individual.net>
In reply to#10498
On 13/08/13 20:29, Twayne wrote:
> Hi All,
>     Seems like I'm getting to be a regular fixture here but ... I'm baaack!
>
> Using win 7, XAMPP, PHP 5.3 & NoteTab, a semi-ide as my text editor:
>
> I've created a Function that works on other pages  but after working for
> some time, no longer functions. I don't think the Function is the
> obvious problem; see below it for more details. The function is:
>
> 109  // FUNCTIONS USED: ------------------------------
> 110
> 111 function check_input($data)
> 112 {
>   113   $data = trim($data);
> 114    $data = stripslashes($data);
> 115    $data = htmlspecialchars($data);
> 116    return $data;
> 117  }
> 118  ?>
> ============== end function =========

As others already has pointed out, it's not the functions fault.


> That code resides at the end of the php page in question so there is
> normally nothing after it but a session_destroy() and a die(); Message
> has been e-mailed. The error message is:
>
> ----------- error message ----------------
> Parse error: syntax error, unexpected $end in C:\xampp\htdocs\twa2.php
> on line 114
> ----------- end error message -----------

Without seeing the whole code it's difficult to tell what's wrong, there 
is patebin.com which could be a good place to post the code and just 
post the link here.


Some advice which can help you in the future:

1. use the phplint feature, it will in this case give you the same 
error, but you don't have to use the browser.

php -l script_name.php

2. Use a version control system like git, this will give you the good 
opportunity to see what changed in the code and it's easier to see what 
is wrong. See http://githowto.com

 From own experience, I have worked at companies where they do not have 
version control at all, which makes it impossible to revert to a working 
version. I have worked at companies where they have a system where you 
rename files with a number in the end, which makes it difficult to know 
which combination of those changed files will be the correct one for the 
previous working version of the project. IMHO it's just stupid to not 
use tools which makes things a lot easier to keep track of and gives you 
a lot of other features which are useful while developing a site.

3. Separate HTML and PHP code as much as possible, have your functions 
in include scripts, you have then include in the top of the "HTML" page, 
this makes it easier to get the right highlight for the PHP and HTML (in 
mixed PHP/HTML files the highlighting may not be correct) and having 
include scripts, then you don't duplicate functions.

4. Check for input that has been written in wrong charset, for example 
some ISO-8859 characters in an UTF-8 encoded page can make PHP to get 
acting strangely and you can't see them.


> Realizing PHP's often misleading line numbers, I went through each and
> every use of the function call on the entire page.

Line number tends to be after the error.

Not the only language having it like that.

[toc] | [prev] | [next] | [standalone]


#10513

FromTwayne <nobody@spamcop.net>
Date2013-08-15 18:17 -0400
Message-ID<kujk2c$3vf$1@speranza.aioe.org>
In reply to#10509
On 2013-08-14 1:10 AM, J.O. Aho wrote:
> On 13/08/13 20:29, Twayne wrote:
>> Hi All,
>
> As others already has pointed out, it's not the functions fault.

Wow, KUDOS for an informative post! I DO seem to recall coming across an 
8859/Unicode mixup; I didn't think anything of it at the time; I see now 
that might gave been a big mistake!
>
>
...

>
> Without seeing the whole code it's difficult to tell what's wrong, there
> is patebin.com which could be a good place to post the code and just
> post the link here.
>

Agreed. And:
It seems you have provided some excellent "for the future" fodder here, 
and I'll look into all of them. THANKS, because they are all sites I'm 
as yet not familiar with.

>
> Some advice which can help you in the future:
>
> 1. use the phplint feature, it will in this case give you the same
> error, but you don't have to use the browser.

That's really appealing!
>
> php -l script_name.php
>
> 2. Use a version control system like git, this will give you the good
> opportunity to see what changed in the code and it's easier to see what
> is wrong. See http://githowto.com
>
>  From own experience, I have worked at companies where they do not have
> version control at all, which makes it impossible to revert to a working
> version. I have worked at companies where they have a system where you
> rename files with a number in the end, which makes it difficult to know
> which combination of those changed files will be the correct one for the
> previous working version of the project. IMHO it's just stupid to not
> use tools which makes things a lot easier to keep track of and gives you
> a lot of other features which are useful while developing a site.

Exactly: my own "archive" purposes to date are my remembering to create 
the backups.
It ight be stupid to not use such tools, but first we have to figure out 
what exists and what's not just crap or so old it's no longer useful. 
Maybe I can tame your version of "stupid"; we'll see.

>
> 3. Separate HTML and PHP code as much as possible, have your functions
> in include scripts, you have then include in the top of the "HTML" page,
> this makes it easier to get the right highlight for the PHP and HTML (in
> mixed PHP/HTML files the highlighting may not be correct) and having
> include scripts, then you don't duplicate functions.

I haven't done much including but was just considering that specific 
possibility. Thanks for confirming, even if it's a no-brainer :).

>
> 4. Check for input that has been written in wrong charset, for example
> some ISO-8859 characters in an UTF-8 encoded page can make PHP to get
> acting strangely and you can't see them.

Interesting; as I said earlier, I do recall such an event being 
discovered and I thought I'd taken care of it; maybe not.

>
>
>> Realizing PHP's often misleading line numbers, I went through each and
>> every use of the function call on the entire page.
>
> Line number tends to be after the error.

Yeah, I've pretty much learned that and only use given line numbers as 
ballpark indicators; it seems the error, warning, notice, whatever give 
more accurate information.

If you happened to notice I've also published a RESOLVED to the thread, 
indicating it seemed like more a hiden character somewhere; perhaps you 
came to a closer estimate.

I sincerely thank you for your post!

Twayne`

>
> Not the only language having it like that.

[toc] | [prev] | [next] | [standalone]


#10511 — Re: Function Problem RESOLVED

FromTwayne <nobody@spamcop.net>
Date2013-08-15 17:28 -0400
SubjectRe: Function Problem RESOLVED
Message-ID<kujh5p$siv$1@speranza.aioe.org>
In reply to#10498
On 2013-08-13 2:29 PM, Twayne wrote:
> Hi All,

...

I've resolved this issue, but I'm afraid I can't tell you HOW. I forgot 
to make a backup of the previously working problem file, so ... what I 
did instead was to rebuild the page from scratch, using the problem file 
as a template.
    First I tried a copy to a new file after renaming the problem file; 
no change.
    So I  started to rebuild the page from scratch, piece by piece, 
waiting for the problem to show itself, but it never did. In the end 
everything worked perfectly.
    All I can suspect that somehow an unprintable character worked its 
way into the code somehow; there WAS a full Byte's size difference 
between the old and the new version of the file.

So go figger, I guess!

Twayne`

>
> Thanks in advance,
>
> Twayne`
>

[toc] | [prev] | [next] | [standalone]


#10512 — Re: Function Problem RESOLVED

FromTim Streater <timstreater@greenbee.net>
Date2013-08-15 23:15 +0100
SubjectRe: Function Problem RESOLVED
Message-ID<timstreater-271821.23152515082013@news.individual.net>
In reply to#10511
In article <kujh5p$siv$1@speranza.aioe.org>,
 Twayne <nobody@spamcop.net> wrote:

> On 2013-08-13 2:29 PM, Twayne wrote:
> > Hi All,
> 
> ...
> 
> I've resolved this issue, but I'm afraid I can't tell you HOW. I forgot 
> to make a backup of the previously working problem file, so ... what I 
> did instead was to rebuild the page from scratch, using the problem file 
> as a template.
>     First I tried a copy to a new file after renaming the problem file; 
> no change.
>     So I  started to rebuild the page from scratch, piece by piece, 
> waiting for the problem to show itself, but it never did. In the end 
> everything worked perfectly.
>     All I can suspect that somehow an unprintable character worked its 
> way into the code somehow; there WAS a full Byte's size difference 
> between the old and the new version of the file.
> 
> So go figger, I guess!

Or use an editor like TextWrangler that has an option to display 
invisibles.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#10514 — Re: Function Problem RESOLVED

FromTwayne <nobody@spamcop.net>
Date2013-08-15 18:59 -0400
SubjectRe: Function Problem RESOLVED
Message-ID<kujmgl$93k$1@speranza.aioe.org>
In reply to#10512
On 2013-08-15 6:15 PM, Tim Streater wrote:
> In article <kujh5p$siv$1@speranza.aioe.org>,
> Twayne <nobody@spamcop.net> wrote:
> H
>> On 2013-08-13 2:29 PM, Twayne wrote:
>> > Hi All,
>>
>> ...
>>
>> I've resolved this issue, but I'm afraid I can't tell you HOW. I
>> forgot to make a backup of the previously working problem file, so ...
>> what I did instead was to rebuild the page from scratch, using the
>> problem file as a template.

...

> Or use an editor like TextWrangler that has an option to display
> invisibles.
>

Hmm, sounds good. Do you actually use that app? Just asking 'cause if 
not, I'll research its reputation a lot closer.

Regards,

Twayne`

[toc] | [prev] | [next] | [standalone]


#10518 — Re: Function Problem RESOLVED

FromTim Streater <timstreater@greenbee.net>
Date2013-08-16 08:50 +0100
SubjectRe: Function Problem RESOLVED
Message-ID<timstreater-21EFDF.08505216082013@news.individual.net>
In reply to#10514
In article <kujmgl$93k$1@speranza.aioe.org>,
 Twayne <nobody@spamcop.net> wrote:

> On 2013-08-15 6:15 PM, Tim Streater wrote:
> > In article <kujh5p$siv$1@speranza.aioe.org>,
> > Twayne <nobody@spamcop.net> wrote:
> > H
> >> On 2013-08-13 2:29 PM, Twayne wrote:
> >> > Hi All,
> >>
> >> ...
> >>
> >> I've resolved this issue, but I'm afraid I can't tell you HOW. I
> >> forgot to make a backup of the previously working problem file, so ...
> >> what I did instead was to rebuild the page from scratch, using the
> >> problem file as a template.
> 
> ...
> 
> > Or use an editor like TextWrangler that has an option to display
> > invisibles.
> >
> 
> Hmm, sounds good. Do you actually use that app? Just asking 'cause if 
> not, I'll research its reputation a lot closer.

I've got two windows permanently open with something like 100 files 
open, as I modify these fairly constantly. The other nice feature is 
that after a quite of the app or restart it starts up by itself [1] and 
opens all those files again.

[1] it's one of my login items.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#10556 — Re: Function Problem RESOLVED

FromTwayne <nobody@spamcop.net>
Date2013-08-17 13:41 -0400
SubjectRe: Function Problem RESOLVED
Message-ID<kuocjn$kun$1@speranza.aioe.org>
In reply to#10518
On 2013-08-16 3:50 AM, Tim Streater wrote:
> In article <kujmgl$93k$1@speranza.aioe.org>,
> Twayne <nobody@spamcop.net> wrote:
>
>> On 2013-08-15 6:15 PM, Tim Streater wrote:
>> > In article <kujh5p$siv$1@speranza.aioe.org>,
>> > Twayne <nobody@spamcop.net> wrote:
>> > H
>> >> On 2013-08-13 2:29 PM, Twayne wrote:
>> >> > Hi All,
>> >>
>> >> ...
>> >>
>> >> I've resolved this issue, but I'm afraid I can't tell you HOW. I
>> >> forgot to make a backup of the previously working problem file, so ...
>> >> what I did instead was to rebuild the page from scratch, using the
>> >> problem file as a template.
>>
>> ...
>>
>> > Or use an editor like TextWrangler that has an option to display
>> > invisibles.
>> >
>>
>> Hmm, sounds good. Do you actually use that app? Just asking 'cause if
>> not, I'll research its reputation a lot closer.
>
> I've got two windows permanently open with something like 100 files
> open, as I modify these fairly constantly. The other nice feature is
> that after a quite of the app or restart it starts up by itself [1] and
> opens all those files again.
>
> [1] it's one of my login items.
>

Many of the editors I've used do that also, including noteTab Pro which 
I use the most. All it takes is to set the option to start with windows. 
Otherwise it does same if you simply open the program again; it opens 
all the files, which can also be opened by making a different group the 
default if you want something you've already sent as a group. I find 
opening the last used set of files, whether in a group or not, to be 
very convenient.

Twayne`

[toc] | [prev] | [next] | [standalone]


#10521 — Re: Function Problem RESOLVED

FromNorman Peelman <npeelman@cfl.rr.com>
Date2013-08-16 06:43 -0400
SubjectRe: Function Problem RESOLVED
Message-ID<kukvo5$p8e$1@dont-email.me>
In reply to#10511
On 08/15/2013 05:28 PM, Twayne wrote:
> On 2013-08-13 2:29 PM, Twayne wrote:
>> Hi All,
>
> ....
>
> I've resolved this issue, but I'm afraid I can't tell you HOW. I forgot
> to make a backup of the previously working problem file, so ... what I
> did instead was to rebuild the page from scratch, using the problem file
> as a template.
>     First I tried a copy to a new file after renaming the problem file;
> no change.
>     So I  started to rebuild the page from scratch, piece by piece,
> waiting for the problem to show itself, but it never did. In the end
> everything worked perfectly.
>     All I can suspect that somehow an unprintable character worked its
> way into the code somehow; there WAS a full Byte's size difference
> between the old and the new version of the file.
>
> So go figger, I guess!
>
> Twayne`
>
>>
>> Thanks in advance,
>>
>> Twayne`
>>
>

   Now that you mention it, there was an oddity in your original post. 
Notice line 113 is indented by 1 space/? character but yet the code for 
line 113 is not. Wonder if that was the culprit?

-- 
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.php


csiph-web