MyBB-Plugins Forums

Full Version: [dev]db query in my MyPlaza module error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
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'])

This will check if the uid is not 0 (guests dont have uid)
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:
 *   Steal Money module
 *     - For MyPlaza for MyBB 1.4*
 *    By, 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"        => "",
"author"        => "TalkForStuff",
"authorsite"    => "",
"version"        => "1.0",
$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!";
// add your items in the _activate() function
function stealmoney_activate() {
// stop people trying to activate this module as a MyBB plugin
cperror('This is not a normal MyBB plugin!  Please upload this file to your /inc/plugins/myplaza directory. - TalkForStuff.Com Steal Money module.');
"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() {

// 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'];
$usermoney 100 || $maybewin "1")
$buyRtnMsg $lang->stealmoney_stealfromnotenough;
$maybewin "0")
$buyRtnMsg $lang->stealmoney_failed;
$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:
<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.
Does it show that error in black letters or just in html?

dont use $_GET, use $mybb->input['usernametostealfrom'] instead
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..
Then it's a parsing error in your module, search for missing ;, extra ), etc
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... =/
Yeh what's the line?
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:
==> will the above add money, or change it to what $rndmoney is?
- Shadows.
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
Pages: 1 2