Hi,
I think there are two double quotes missing:
"INSERT INTO mysql.user VALUES password(\"$pass\");"
Since $pass is a string you need to put " around it. But that wouldn't work either because the table has more than one field and the password itself isn't sufficient.
Example:
"INSERT INTO mysql.user (Host,User,Password) VALUES (\"%\",\"myuser\",password(\"$pass\"));"
This user would then have no rights. To give a user all rights you can do something like:
$strSQL = <<< EOSQL
INSERT INTO mysql.user VALUES ("%","myuser",password("$pass"),
"Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y")
EOSQL;
This might be a bad idea. The MySQL manual has an overview about the meaning of the different privileges.
You might want to insert a user without any rights into user and then give that user specific rigthts on one or more databases by inserting rows into the mysql.db table.
After that you must execute the query
FLUSH PRIVILEGES
to activate the changes.
Instead of inserting the rows manually you can also use a GRANT query to give certain users privileges.