Click here to Skip to main content
14,920,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm kinda new to php, i was doing function and this syntax error happened

function invalidUid($username) {
if (!preg_match("/^[a-zA-Z0-9]*$/"), $username) { #that is line 15
    $result = true;
else {
    $result = false;
return $result;

What I have tried:

Updated 9-Feb-21 7:35am

1 solution

You just need to match up your parentheses:

if (!preg_match("/^[a-zA-Z0-9]*$/", $username))

preg_match takes 2 (or more) parameters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900