Results 1 to 6 of 6
  1. #1
    xMrSiiNz's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    [PHP] Custom SB command not working?

    I can't get this to work, if someone could help me it'd be much appreciated. I'd rather not show the whole code.

    Code:
                      elseif (preg_match("#^(/rename\s+?)#i", $message, $matches) && $db->isAdmin()) {
    			$rename = $db->sanitize(trim(str_replace($matches[0], "", $message)));
    			$selectuser = $con->query("SELECT * FROM users WHERE username='$rename'");
    			$checkuser = $con->query("SELECT * FROM users WHERE username='$matches[0]'");
    			if(!$selectuser or !$checkuser)
    			{
    				echo $con->mysql_error();
    			}
    			else
    			{
    				if($selectuser && !$checkuser)
    				{
    					$con->query("UPDATE users SET Username='$matches[0]' WHERE Username='$rename'");
    					$message = ' has changed the user '.$user.'\'s username to '.$matches[0].'.';
    				}
    				else
    				{
    					$message = 'The username you have entered is invalid or already taken.';
    				}
    			}
                     }

  2. #2
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    What is it doing, or, not doing?

    maybe the "or" on line 5 should be "||"
    Last edited by abuckau907; 04-03-2014 at 09:03 PM.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  3. #3
    xMrSiiNz's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by abuckau907 View Post
    What is it doing, or, not doing?

    maybe the "or" on line 5 should be "||"
    It's not doing anything, not even throwing a error. You can use "or".

  4. #4
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    You're not giving me much to go off of...

    elseif (preg_match("#^(/rename\s+?)#i", $message, $matches) && $db->isAdmin()) {
    echo "Path1 taken <br />";
    $rename = $db->sanitize(trim(str_replace($matches[0], "", $message)));
    $selectuser = $con->query("SELECT * FROM users WHERE username='$rename'");
    $checkuser = $con->query("SELECT * FROM users WHERE username='$matches[0]'");
    if(!$selectuser or !$checkuser)
    {
    echo "Path2 taken <br />";
    echo $con->mysql_error();
    }
    else
    {
    if($selectuser && !$checkuser)
    {
    echo "Path3 taken <br />";
    $con->query("UPDATE users SET Username='$matches[0]' WHERE Username='$rename'");
    $message = ' has changed the user '.$user.'\'s username to '.$matches[0].'.';
    }
    else
    {
    echo "Path4 taken <br />";
    $message = 'The username you have entered is invalid or already taken.';
    }
    }
    }
    Which output(s) do you get?

    edit: Please describe your problem more than "it won't work/nothing happens" ..else I can't help.
    tip: sprinkle more echo's into your code so you know which pieces of code are actually being executed/the path of execution.
    Last edited by abuckau907; 04-04-2014 at 11:39 PM. Reason: used cout instead of echo : p
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  5. #5
    marceliino's Avatar
    Join Date
    Nov 2009
    Gender
    male
    Location
    gone forever
    Posts
    858
    Reputation
    74
    Thanks
    2,744
    I Can help you if you can post the whole script.
    But with a small snipped like this it's sort of hard to figure out whats the problem.

  6. #6
    greengermbubble's Avatar
    Join Date
    Jul 2014
    Gender
    male
    Posts
    66
    Reputation
    10
    Thanks
    6
    My Mood
    Buzzed
    Your elseif is in an odd spot

Similar Threads

  1. [Solved] PushToConsole Command not working
    By lunatik21 in forum Combat Arms Coding Help & Discussion
    Replies: 4
    Last Post: 06-25-2013, 11:29 AM
  2. [Help Request] Simple PTC command not working
    By amitsl in forum Combat Arms Coding Help & Discussion
    Replies: 12
    Last Post: 04-08-2013, 04:15 PM
  3. Vindictus uSa secondary weapons commands not working
    By olox123 in forum Vindictus Help
    Replies: 8
    Last Post: 03-26-2012, 08:58 PM
  4. Command not working
    By m202 in forum Vindictus Discussions
    Replies: 4
    Last Post: 03-18-2011, 04:21 PM
  5. changemap command not working?
    By zeekond in forum Vindictus Discussions
    Replies: 3
    Last Post: 02-03-2011, 04:24 PM