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
Return to the default flat view Create a new topic Submit Reply
Re: Function Problem [message #182556 is a reply to message #182545] Wed, 14 August 2013 05:10 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Email attachment 0bytes using php4
Next Topic: AND and OR
Goto Forum:
  

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

Current Time: Thu Sep 19 12:42:11 GMT 2024

Total time taken to generate the page: 0.05611 seconds