Jump to content
MakeWebGames

Adjust User Level error


Mystical

Recommended Posts

There is an error in staff_special.php for v2.0.3. When I try to update a users level I get this message. Error: This script requires an action. I saw Illusions fix in another thread but after I added the fix I still get the exact same error. Any help would be appreciated.

Link to comment
Share on other sites

There is no action meaning one of the links you clicked on didnt direct to an action in the script in which it goes to...

Or the action function is not in the script... post your staff_special.php then others can see what link or action is missing.

 

For an example...

You have in smenu.php

<a href='staff_special.php?action=userlevelform'>Adjust User Level</a>

Then see where the "action=" is? The "userlevelform" is the action...

That action should be a function in your staff_special.php....

The link from your menu may be missing an action, or just says

<a href='staff_special.php'>... You need to correct it and add an action, if the action is there, make sure it is correctly spelt, if that is fine then the problem is in your staff_special.php, may be missing the action function...

Edited by lucky3809
Link to comment
Share on other sites

There is no action meaning one of the links you clicked on didnt direct to an action in the script in which it goes to...

Or the action function is not in the script... post your staff_special.php then others can see what link or action is missing.

 

For an example...

You have in smenu.php

<a href='staff_special.php?action=userlevelform'>Adjust User Level</a>

Then see where the "action=" is? The "userlevelform" is the action...

That action should be a function in your staff_special.php....

The link from your menu may be missing an action, or just says

<a href='staff_special.php'>... You need to correct it and add an action, if the action is there, make sure it is correctly spelt, if that is fine then the problem is in your staff_special.php, may be missing the action function...

Here is the part in question and thanks!

function userlevel() {

global $db,$ir,$c,$h,$userid;

$_GET['level'] = ( isset($_GET['level'])&&in_array($_POST['level'], array(1,2,3,4,5)) )?abs(intval($_GET['level'])):1;

$_GET['ID'] = ( isset($_GET['ID'])&&is_numeric($_GET['ID']) )?abs(intval($_GET['ID'])):'';

$d = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_POST['ID']);

if ( $db->num_rows($d) == 0 ) {

echo 'Invalid user.<br />> <a href="staff_special.php?action=userlevelform">Go Home</a>';

die($h->endpage());

}

$db->query("UPDATE `users` SET `user_level` = {$_GET['level']} WHERE `userid` = {$_GET['ID']}");

stafflog_add('Adjusted user ID '.$_GET['ID'].'\'s staff status.');

echo 'User\'s level adjusted.<br />> <a href="staff.php">Go Home</a>';

die($h->endpage());

}

function userlevelform() {

global $db,$ir,$c,$h,$userid;

echo "

<h3>User Level Adjust</h3>

<form action='staff_special.php?action=userlevel' method='get'>

User: ".user_dropdown($c,'ID')."

<br />

User Level:

<br />

<input type='radio' name='level' value='1' /> Member

<br />

<input type='radio' name='level' value='2' /> Admin

<br />

<input type='radio' name='level' value='3' /> Secretary

<br />

<input type='radio' name='level' value='4' /> IRC Op

<br />

<input type='radio' name='level' value='5' /> Assistant

<br />

<input type='submit' value='Adjust' />

</form>

Link to comment
Share on other sites

Ok your functions is not the problem... its the link in your smenu page

where it should say...

<a href='staff_special.php?action=userlevelform'>Adjust User Level</a>

If it does not have that then copy and paste that line... it should work evidently the smenu page links are not linking to the actions...

Which the action is...

userlevelform... which directs the link when clicked to the form...

Edited by lucky3809
Link to comment
Share on other sites

That is exactly what the link looks like <a href='staff_special.php?action=userlevelform'>Adjust User Level</a><br />. When I change those functions to the old version in 2.0.2c it works like a charm so it must be something in the way the one of the two functions are coded in the new version 2.0.3.

Link to comment
Share on other sites

Change the form method to post and all the variables to $_POST rather than $_GET

 

Still cant figure it out because your talking to a moron when it comes to coding. I also found another error in the same file. When you go to staff list clicking on the links secretary assistant or member will get you this message: QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Query was SELECT `userid` FROM `users` WHERE `userid` =

Link to comment
Share on other sites

Replace those functions with...

function userlevel()

{

global $db,$ir,$c,$h,$userid;

$_GET['level']=abs((int) $_GET['level']);

$_GET['ID']=abs((int) $_GET['ID']);

$db->query("UPDATE users SET user_level={$_GET['level']} WHERE userid={$_GET['ID']}");

print "User's level adjusted.";

stafflog_add("Adjusted user ID {$_GET['ID']}'s staff status.");

}

function userlevelform()

{

global $db,$ir,$c,$h,$userid;

print "<h3>User Level Adjust</h3>

<form action='staff_special.php' method='get'>

<input type='hidden' name='action' value='userlevel'>

User: ".user_dropdown($c,'ID')."<br />

User Level:<br />

<input type='radio' name='level' value='1' /> Member<br />

<input type='radio' name='level' value='2' /> Admin<br />

<input type='radio' name='level' value='3' /> Secretary<br />

<input type='radio' name='level' value='4' /> IRC Op<br />

<input type='radio' name='level' value='5' /> Assistant<br />

<input type='submit' value='Adjust' /></form>";

}

 

Your getting that query error because it may have not inserted the ID.

Link to comment
Share on other sites

haha didnt see it until now but take a look at your script...

function userlevel() {

global $db,$ir,$c,$h,$userid;

$_GET['level'] = ( isset($_GET['level'])&&in_array($_POST['level'], array(1,2,3,4,5)) )?abs(intval($_GET['level'])):1;

$_GET['ID'] = ( isset($_GET['ID'])&&is_numeric($_GET['ID']) )?abs(intval($_GET['ID'])):'';

$d = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_POST['ID']);

if ( $db->num_rows($d) == 0 ) {

echo 'Invalid user.<br />> <a href="staff_special.php?action=userlevelform">Go Home</a>';

die($h->endpage());

 

See whats wrong? There is 2 $_POST when it should be $_GET

Your script probably works fine now that i changed those...

function userlevel() {

global $db,$ir,$c,$h,$userid;

$_GET['level'] = ( isset($_GET['level'])&&in_array($_GET['level'], array(1,2,3,4,5)) )?abs(intval($_GET['level'])):1;

$_GET['ID'] = ( isset($_GET['ID'])&&is_numeric($_GET['ID']) )?abs(intval($_GET['ID'])):'';

$d = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_GET['ID']);

if ( $db->num_rows($d) == 0 ) {

echo 'Invalid user.<br />> <a href="staff_special.php?action=userlevelform">Go Home</a>';

die($h->endpage());

}

$db->query("UPDATE `users` SET `user_level` = {$_GET['level']} WHERE `userid` = {$_GET['ID']}");

stafflog_add('Adjusted user ID '.$_GET['ID'].'\'s staff status.');

echo 'User\'s level adjusted.<br />> <a href="staff.php">Go Home</a>';

die($h->endpage());

}

function userlevelform() {

global $db,$ir,$c,$h,$userid;

echo "

<h3>User Level Adjust</h3>

<form action='staff_special.php?action=userlevel' method='get'>

User: ".user_dropdown($c,'ID')."

<br />

User Level:

<br />

<input type='radio' name='level' value='1' /> Member

<br />

<input type='radio' name='level' value='2' /> Admin

<br />

<input type='radio' name='level' value='3' /> Secretary

<br />

<input type='radio' name='level' value='4' /> IRC Op

<br />

<input type='radio' name='level' value='5' /> Assistant

<br />

<input type='submit' value='Adjust' />

</form>

Edited by lucky3809
Link to comment
Share on other sites

I just bought version 2.0.3 last night and after we got it installed on our host and started playing around we found this same problem. I will try this fix when I get home tonight but I assume this means the engine is not working out of the box and there will probably be other bugs to fix?

Link to comment
Share on other sites

Google do have bugs too. No software is without bugs, it's simply impossible. Simply on some softs you see the bugs more than others, or actually some bugs are easier to spots than others. Of course some softs do have better quality than others.

Now for most developers, bugs are part of software which do not work as planned or should.

Link to comment
Share on other sites

  • 10 months later...

This didnt work for me unless im just not seeing it but here is my code

function userlevel() {
global $db,$ir,$c,$h,$userid;
	$_GET['level'] = ( isset($_GET['level'])&&in_array($_GET['level'], array(1,2,3,4,5)) )?abs(intval($_GET['level'])):1;
	$_GET['ID'] = ( isset($_GET['ID'])&&is_numeric($_GET['ID']) )?abs(intval($_GET['ID'])):'';
$d = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_GET['ID']);
    if ( $db->num_rows($d) == 0 ) {
  echo 'Invalid user.<br />> <a href="staff_special.php?action=userlevelform">Go Home</a>';
  die($h->endpage());
    }
$db->query("UPDATE `users` SET `user_level` = {$_GET['level']} WHERE `userid` = {$_GET['ID']}");
	stafflog_add('Adjusted user ID '.$_GET['ID'].'\'s staff status.');
  echo 'User\'s level adjusted.<br />> <a href="staff.php">Go Home</a>';
  die($h->endpage());
}
function userlevelform() {
global $db,$ir,$c,$h,$userid;
echo "
<h3>User Level Adjust</h3>
<form action='staff_special.php?action=userlevel' method='get'>
User: ".user_dropdown($c,'ID')."
<br />
User Level:
<br />
<input type='radio' name='level' value='1' /> Member
<br />
<input type='radio' name='level' value='2' /> Admin
<br />
<input type='radio' name='level' value='3' /> Secretary
<br />
<input type='radio' name='level' value='4' /> Assistant
<br />
<input type='radio' name='level' value='5' /> Forum Mod
<br />
<input type='submit' value='Adjust' />
</form>
";
Link to comment
Share on other sites

You need to edit the link;

I'm unsure what the actual case name is, so;

- Open the file.

- Find the case section of the file

- Find the case name of the function you want to link to

- Edit the link

(Normally, McCodes uses this <a href='file.php?action=casename'>Something</a>)

Personally, I don't like the default case returning that error, it would be so much more user friendly if it returned links to the functions...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...