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

Home » Imported messages » comp.lang.php » Function Problem
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Function Problem [message #182545] Tue, 13 August 2013 18:29 Go to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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`
Re: Function Problem [message #182546 is a reply to message #182545] Tue, 13 August 2013 20:57 Go to previous messageGo to next message
Paul Herber is currently offline  Paul Herber
Messages: 26
Registered: February 2011
Karma: 0
Junior Member
On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody(at)spamcop(dot)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
Re: Function Problem [message #182547 is a reply to message #182546] Tue, 13 August 2013 21:26 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 8/13/2013 4:57 PM, Paul Herber wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody(at)spamcop(dot)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(at)attglobal(dot)net
==================
Re: Function Problem [message #182548 is a reply to message #182545] Tue, 13 August 2013 23:25 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
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?-
Re: Function Problem [message #182549 is a reply to message #182546] Tue, 13 August 2013 23:29 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-13 4:57 PM, Paul Herber wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody(at)spamcop(dot)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`
Re: Function Problem [message #182550 is a reply to message #182545] Tue, 13 August 2013 23:34 Go to previous messageGo to next message
David Robley is currently offline  David Robley
Messages: 23
Registered: March 2013
Karma: 0
Junior Member
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.
Re: Function Problem [message #182551 is a reply to message #182548] Tue, 13 August 2013 23:39 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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`
Re: Function Problem [message #182552 is a reply to message #182545] Tue, 13 August 2013 23:48 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody(at)spamcop(dot)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.
Re: Function Problem [message #182553 is a reply to message #182550] Wed, 14 August 2013 00:45 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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`
PS Re: Function Problem [message #182554 is a reply to message #182550] Wed, 14 August 2013 00:51 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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`
Re: Function Problem [message #182555 is a reply to message #182552] Wed, 14 August 2013 01:00 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-13 7:48 PM, Richard Yates wrote:
> On Tue, 13 Aug 2013 14:29:09 -0400, Twayne <nobody(at)spamcop(dot)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`
Re: Function Problem [message #182556 is a reply to message #182545] Wed, 14 August 2013 05:10 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 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.
Re: Function Problem [message #182557 is a reply to message #182549] Wed, 14 August 2013 09:24 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
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.
Re: Function Problem RESOLVED [message #182558 is a reply to message #182545] Thu, 15 August 2013 21:28 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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`
>
Re: Function Problem RESOLVED [message #182559 is a reply to message #182558] Thu, 15 August 2013 22:15 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kujh5p$siv$1(at)speranza(dot)aioe(dot)org>,
Twayne <nobody(at)spamcop(dot)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
Re: Function Problem [message #182560 is a reply to message #182556] Thu, 15 August 2013 22:17 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
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.
Re: Function Problem RESOLVED [message #182561 is a reply to message #182559] Thu, 15 August 2013 22:59 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-15 6:15 PM, Tim Streater wrote:
> In article <kujh5p$siv$1(at)speranza(dot)aioe(dot)org>,
> Twayne <nobody(at)spamcop(dot)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`
Re: Function Problem RESOLVED [message #182565 is a reply to message #182561] Fri, 16 August 2013 07:50 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <kujmgl$93k$1(at)speranza(dot)aioe(dot)org>,
Twayne <nobody(at)spamcop(dot)net> wrote:

> On 2013-08-15 6:15 PM, Tim Streater wrote:
>> In article <kujh5p$siv$1(at)speranza(dot)aioe(dot)org>,
>> Twayne <nobody(at)spamcop(dot)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
Re: Function Problem RESOLVED [message #182568 is a reply to message #182558] Fri, 16 August 2013 10:43 Go to previous messageGo to next message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma: 0
Senior Member
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?-
Re: Function Problem RESOLVED [message #182603 is a reply to message #182565] Sat, 17 August 2013 17:41 Go to previous messageGo to next message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 3:50 AM, Tim Streater wrote:
> In article <kujmgl$93k$1(at)speranza(dot)aioe(dot)org>,
> Twayne <nobody(at)spamcop(dot)net> wrote:
>
>> On 2013-08-15 6:15 PM, Tim Streater wrote:
>>> In article <kujh5p$siv$1(at)speranza(dot)aioe(dot)org>,
>>> Twayne <nobody(at)spamcop(dot)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`
Re: Function Problem RESOLVED [message #182604 is a reply to message #182568] Sat, 17 August 2013 17:44 Go to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma: 0
Senior Member
On 2013-08-16 6:43 AM, Norman Peelman wrote:
> 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?
>

Mmm, good catch! I never noticed that. I think I'll dig into my archives
and search for it so I can see if you're right.

Thanks for a great lead! Now if I can only find it in the archives! :)

Regards,

Twayne`
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Email attachment 0bytes using php4
Next Topic: AND and OR
Goto Forum:
  

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

Current Time: Sun Dec 01 02:53:23 GMT 2024

Total time taken to generate the page: 0.02636 seconds