Hi, first of all I need to say that I am a complete moron at this. My php and Drupal coding "skills" are minimum at best, I try to get through by looking at examples of code and tweaking it to serve my need - which obviously means that it isn't going to work in most cases.
I've, however, tried to make a simple module based on Userpoints. It essentially converts the current user points of a user into a specific level. Fairly straightforward, I thought - but I end up with errors.
Here is the (ugly) code:
<?php
function havoclevel_level_storage($level = NULL, $uid = NULL) {
db_merge('havoclevel_level_storage')
->key(array('uid' => $uid, 'level' => $level))
->execute();
}
function havoclevel_level_up($transaction) {
$xp = userpoints_get_current_points($uid, 'all');
if ($xp >= 0 && $xp <= 49) { havoclevel_level_storage($level = 1, $transaction->uid)
elseif ($xp >= 50 && $xp <= 149) { havoclevel_level_storage($level = 2, $transaction->uid) }
elseif ($xp >= 150 && $xp <= 299) { havoclevel_level_storage($level = 3, $transaction->uid) }
}
}
havoclevel is the name of the module. This specific code gives me a "Parse error: syntax error, unexpected T_ELSE" error. I am fairly confident that the issue is not that, but rather that $xp is not properly defined - but I have no idea why not.