Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

So I got this error:

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\scanner\mine.php on line 112

On this line:

if(preg_match("inurl:", $text) {

Its part of a "Clean" function:

  function Clean($text) {
        if(preg_match("inurl:", $text) {
            str_replace("inurl:", "", $text);
            return htmlspecialchars($text, ENT_QUOTES);
        } else {
            return htmlspecialchars($text, ENT_QUOTES);
        }
  }

How can I fix it?

share|improve this question

closed as too localized by uınbɐɥs, cryptic ツ, syb0rg, nickhar, Fls'Zen Apr 28 '13 at 0:08

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
You forgot a closing ) in that line – Ram Jul 13 '11 at 21:03
    
You forgot a closing ) + a semicolon in the end of str_replace + str_replace it self won't do anything in your code, you should add "$text = " be4 it :) – Pezhvak IMV Jul 13 '11 at 21:09

Two problems, One closing ) and a missing semicolon after str_replace, also you should know your str_replace won't do anything in your code so i added $text = ... :)

  function Clean($text) {
        if(preg_match("inurl:", $text)) {
            $text = str_replace("inurl:", "", $text);
            return htmlspecialchars($text, ENT_QUOTES);
        } else {
            return htmlspecialchars($text, ENT_QUOTES);
        }
  }
share|improve this answer

Add another ):

if(preg_match("inurl:", $text)) {
share|improve this answer

You're missing the closing ) on your if statement.

Should be:

if(preg_match("inurl:", $text)) {

You're also missing your statement terminator on the string replace. That should be:

str_replace("inurl:", "", $text);
share|improve this answer

You left out the ) for the if condition.

  if
    (
      preg_match(
        "inurl:", $text
      ) 
    {
share|improve this answer

The if clause is superfluous anyway. The following function is equivalent to the original version (sans the non-compiling regex pattern).

function Clean($text)
{
    $text = str_replace("inurl:", "", $text);
    return htmlspecialchars($text, ENT_QUOTES);
}

If the string you want to replace is not found in the haystack, str_replace won't do anything. So it is safe to run the function unconditionally.

In the original version, you'd also have to surround the regex pattern for preg_match with delimiters (see: http://www.php.net/manual/en/regexp.reference.delimiters.php). (In this case, strpos would do the job, too.)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.