Home > database >  Where is the error in my code? syntax error, unexpected token "," (PHP)
Where is the error in my code? syntax error, unexpected token "," (PHP)

Time:09-07

I am a total beginner on PHP so that is why I can't find what the error is... it seems very simple but I can't find it, this is the part of my code that is giving me trouble:

function invalidRUT($username) {
$result;
if (!preg_match("/^[0-9]*$/"), $username) {
    $result = true;
}
else {
    $result = false;
}
return $result;
}

And the error message is: syntax error, unexpected token "," (lin 15, col.5)

CodePudding user response:

Try this: (fixed code)

function invalidRUT($username) {
$result;
if (!preg_match("/^[0-9]*$/", $username)) {
    $result = true;
}
else {
    $result = false;
}
return $result;
}

CodePudding user response:

you accidentally wrote "," in your code and it caused an error, please delete or replace the ","

  • Related