1.3.4 help with inserting Forum info to DB

Forum
Last Post
Threads / Messages

Ittermat

The awesomesauce
Member
Joined
Feb 2, 2016
Messages
304
Points
18
Location
in front of my laptop
Mysidian Dollar
21,294
EDIT TWO: Got it working- heres what you need in case you need to do what I needed to do. Thank you to Nullwaves on the discord!

$forums = new Database($mybbdbname, $mybbhost, $mybbuser, $mybbpass, $mybbprefix) or die("Cannot connect to forum database, please contact an admin immediately.");

$forums->update("users", array("additionalgroups" => "10"), "uid = '{$mysidia->user->uid}'");

(you would of course change this to what you need it to update..)

And dont forget
include("inc/config_forums.php");
under the mysidia registry call.




EDIT: I think this is the better approach. but still cant get it to work..

So Im trying to make it so that when I user chooses an alignment it will also add that to thier Forum info... something like



if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$choice = $_REQUEST['fb'];
switch ($choice){
case "light":
$group = "Light Dragon";
break;
case "dark":
$group = "Dark Ghost";
break;
case "collector":
$group = "Brave Collector";
break;
case "knowledge":
$group = "Knowledge Seeker";
break;
}
$document->add(new Comment("<center>You have joined the <b>{$group}</b> alignment! <a href='/alignments'>Go back?</a></center>"));
$mysidia->db->update("users", array("alignment" => $choice), "uid = '$uid'");
//mybbew update code

if ($group= 'Light Dragon'){
$mybbew = Registry::get("mybb779");
$othergroups = $mybbew->db->select("users", array("additionalgroups"), "uid = '$uid'")->fetchColumn();
$mybbew->db->update("users", array("$othergroups" => '11'), "uid = '$uid'");
}
elseif ($group= 'Dark Ghost'){
$mybbew = Registry::get("mybb779");
$othergroups = $mybbew->db->select("users", array("additionalgroups"), "uid = '$uid'")->fetchColumn();
$mybbew->db->update("users", array("$othergroups" => '10'), "uid = '$uid'");
}
elseif ($group= 'Brave Collector'){
$mybbew = Registry::get("mybb779");
$othergroups = mybbew->db->select("users", array("additionalgroups"), "uid = '$uid'")->fetchColumn();
$mybbew->db->update("users", array("$othergroups" => '13'), "uid = '$uid'");
}
elseif ($group= 'Knowledge Seeker'){
$mybbew = Registry::get("mybb779");
$othergroups = $mybbew->db->select("users", array("additionalgroups"), "uid = '$uid'")->fetchColumn();
$mybbew->db->update("users", array("$othergroups" => '12'), "uid = '$uid'");
}


Would this work? or am i missing something? I dont really know how to add info to the mybb db


This is the the error I keep getting:


Fatal error
: Uncaught exception 'Exception' with message 'Cannot retrieve registered object' in /home/atrocity/public_html/classes/class_registry.php:115Stack trace:#0 /home/atrocity/public_html/view/alignmentsview.php(34): Registry::get('atrocity_mybb77...')#1 /home/atrocity/public_html/classes/class_frontcontroller.php(100): AlignmentsView->index()#2 /home/atrocity/public_html/index.php(79): FrontController->render()#3 /home/atrocity/public_html/index.php(83): IndexController::main()#4 {main} thrown in /home/atrocity/public_html/classes/class_registry.php on line 115


so its not Getting the Registry...but im unsure how to fix it..
Im betting my main possible help here is @Hall of Famer Since he connected the forum to my site.
 
Last edited:
It's hard to say without seeing more of the code, but I guess my first question would be, do you use this mybb779 object elsewhere in the codebase, and if so, where is it registered?
 
Thats the thing I dont actually know! Thats why I figured Famer would be the best to help me cuz hes the one that hooked my forum to my website..Im sorry!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top