Hello There, Guest! › Register

MySubscriptions 2.2 released.
Looking for a custom plugin for your site? Ask here for a quote.

[dev]db query in my MyPlaza module error
#1

I'm developing a Steal Money module.
I just have a problem, it says it can't connect, connection error or something liddat, that's all.
I'm sure it's in this lil line, but idk how to solve it =/
PHP Code:
$db->update_query('users', array('money' => 'money + 200'), 'uid='.intval($mybb->user['uid'])); 
Thanks for the support.
Hope i'll be able to release this soon =).
without TABLE_PREFIX . doesn't work neither..
also another question.
How do i check if a user exists?
thanks Big Grin
- Shadows.
#2

I would like to take a look at the error please.
How do you check if a user exists? Like by uid?
PHP Code:
if (!$mybb->user['uid'])
    return 
false

This will check if the uid is not 0 (guests dont have uid)
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#3

well you get an username and check if that username exists in the db but i'm not an sql pro lol.. maybe you know the query? else i'll search mysql site.
Current code i have
PHP Code:
<?php
/*****************************************************************************
 *   Steal Money module
 *     - For MyPlaza for MyBB 1.4*
 *    By Talkforstuff.com, 2009
 * 
 *  Adds an item to steal money from users.
 *  Somtimes it'll fail, sometimes not.
 *****************************************************************************/
function stealmoney_info() {
    return array(
        
"name"            => "Steal money",
        
"description"    => "This will add an item where users can steal money from others, of course they will not always win!",
        
"website"        => "http://www.talforstuff.com/",
        
"author"        => "TalkForStuff",
        
"authorsite"    => "http://www.talkforstuff.com/",
        
"version"        => "1.0",
    );
}
function 
stealmoney_lang()
{
    global 
$lang$mybb;
    switch(
$mybb->settings['bblanguage'])
    {
        default:
            
$lang->stealmoney_success "You have successfully stolen money from the specified user!";
            
$lang->stealmoney_failed "You have lost the money you've bet! Aren't you ashamed?";
            
$lang->stealmoney_stealfromnotenough "The user you are trying to steal money from does not have enough money to steal!";
    }
}
function 
stealmoney_lang_admin()
{
    
stealmoney_lang();
}
// add your items in the _activate() function
function stealmoney_activate() {
    
// stop people trying to activate this module as a MyBB plugin
    
if(!defined("IN_MYPLAZA_ADMIN"))
        
cperror('This is not a normal MyBB plugin!  Please upload this file to your /inc/plugins/myplaza directory. - TalkForStuff.Com Steal Money module.');
        
global 
$lang;
    
myplaza_add_item(array(
        
"name"            => 'Steal money',
        
"description"    => 'Steal 100 money from someone. it will fail or succeed.',
        
"cost"            => 100.00,
        
"htmlextra"     => '<input type="text" name="usernametostealfrom" value="" size="30" />'
    
));
}

// remove all items we added earlier in the _deactivate() function
function stealmoney_deactivate() {
    
myplaza_remove_module_items();
}

// this function handles what is done when buying an item
function stealmoney_run($item) {
    
// add 1000 to the user's post count :)
    
global $mybb$buyRtnMsg$db$lang;
    
    
// this is a custom version of MyBB's $db->update_query
    
$maybewin mt_rand(01);
    
$usertosteal $_GET['usernametostealfrom'];
    
$usermoneyar $db->simple_select(TABLE_PREFIX "users""money""username='{$usertosteal}'");
    
$array $db->fetch_array($query);
    
$usermoney $array['money'];
        if(
$usermoney 100 || $maybewin "1")
        {
            
$buyRtnMsg $lang->stealmoney_stealfromnotenough;
        }
                if(
$maybewin "0")
        {
            
$buyRtnMsg $lang->stealmoney_failed;
        }
    if(
$maybewin "1" || $usermoney 100)
    {
        
$buyRtnMsg $lang->stealmoney_success;
            
$db->update_query('users', array('money' => 'money + 200'), 'uid='.intval($mybb->user['uid']));
            
$db->update_query('users', array('money' => 'money - 100'), 'username='.$_GET['usernametostealfrom']); //UID OF INPUT USER...
    
}
    
    
// everything successful, so return true
    
return true;
}
?>
I know maybe there is something wrong, but some time ago, the db query worked..
The error is just while buying:
Code:
<div style="background: #FBEEF1 url(http://localhost/dev/images/myplaza/error.png) center no-repeat; background-position: 7px 7px; text-align: left; margin: 5px 15px 5px 15px; padding: 13px 20px 13px 45px; border-top: 2px solid #FEABB9; border-bottom: 2px solid #FEABB9; line-height: 150%; font-weight: bold; width: 90%;">A connection error occurred!</div>

Thanks Smile.
- Shadows.
#4

Does it show that error in black letters or just in html?

Edit:
dont use $_GET, use $mybb->input['usernametostealfrom'] instead
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#5

it appears in black letters, it showed up like that.
Ok thanks for the input thingy lol.
Lemme try again.
edit: doesn't work still hm...
it's when you buy it appears and then dissapears in black lettres, that error.
EDIT2: shouldn't it be $_POST? becuz it's from the html input.. it's not from the url? hmm not sure..
#6

Then it's a parsing error in your module, search for missing ;, extra ), etc
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#7

Quote:shouldn't it be $_POST? becuz it's from the html input.. it's not from the url? hmm not sure..
@ -- doesn't it show up a parse_error in the ACP modules then?
--> yea it does, just tested.
hmm really weird this time..
lemme try and install a new mybb on localhost, maybe i messed up that one already ^^ xD
EDIT: just tried in fresh install, still doesn't work... =/
#8

Yeh what's the line?
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.
#9

No i mean it should show a parse_error in ACP if there's any but there is none =/
- Shadows.
Lemme test a few things..
edit: Is there a place i can find all functions like these?
PHP Code:
            user_change_money($mybb->user$rndmoney); 
==> will the above add money, or change it to what $rndmoney is?
- Shadows.
#10

You should search for that function in myplaza_general.php
as the comment says "Is the ammount of money to add". If negative will subract of course.

There's no place where you can find ALL functions but you can find some in the old_documentation folder. Search for a dev- something html file
Shadows from my experience with errors like that one, it's an error. Try checking the Options of your module, should give an error. If does not show any errors, just comment things until you find out whats wrong
To download our paid plugins and receive support you must be a paid subscriber. Click here for more information.




Users browsing this thread: 1 Guest(s)