Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try this:
(fixed code)

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading