Jump to content


Photo

Parsing error


  • Please log in to reply
2 replies to this topic

#1 Saragon

Saragon
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 09 June 2006 - 05:50 PM

The following is lifted straight out of Christian Wenz's "PHP Phrasebook: Essential Code and Commands". It's a handy function designed to clean extra "magic quotes" slashes out of form data.

Unfortunately, it's throwing a parse error that seems completely unreasonable. The error is as follows:
Parse error: parse error, unexpected '{', expecting '(' in [server root]/[subdirectories]/stripFormSlashes.inc.php on line 2

1 <?php
2     function stripFormSlashes{$arr}
3     {
4       if (!is_array($arr)) {
5         return stripslashes($arr);
6       } else {
7         return array_map('stripFormSlashes', $arr);
8       }
9     }
10    
11     if(get_magic_quotes_gpc()) {
12       $_GET  = stripFormSlashes($_GET);
13       $_POST = stripFormSlashes($_POST);
14     }
15 ?>

I'm calling this with the following:
<?php require_once 'stripFormSlashes.inc.php'; ?>

Now, as near as I can tell, line 2 is just fine. So is the rest of the code, for that matter -- I've no unclosed parentheses anywhere. Nonetheless, it simply will not parse. What obvious thing have I overlooked here?

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 09 June 2006 - 06:04 PM

Don't use curly brackts, but round brackets or parentheses:

function stripFormSlashes($arr)

~ D Kuang

#3 Saragon

Saragon
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 09 June 2006 - 06:07 PM

[!--quoteo(post=381981:date=Jun 9 2006, 02:04 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 9 2006, 02:04 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Don't use curly brackts, but round brackets or parentheses:

function stripFormSlashes($arr)
[/quote]

I also apparently need to get my eyes checked. Or I need to get a new monitor -- I can barely distinguish between the two in PHP Designer `06. Hmm.

Thanks, Poirot.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users