The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with $dv->update
#1
Hi

So heres the code I am using... but it doesnt seem to update the db... I cant seem to figure out where I am going wrong:

require_once $abs_us_root.$us_url_root.'users/classes/DB.php';'

$db = DB::getInstance();
$updatestatus = Input::Get('update');
$qid = Input::Get('id');

if ($updatestatus != 1) {
$fields = array(
'author' => $user->data()->id,
'filenumber' => Input::get('internal'),
'content' => Input::get('letterbody'),
'webkey' => Token::generate(),
);
$db->insert('letters',$fields);
Redirect::to('lettersearch.php?msg=Letter+Saved!');
}
else {
$fields = array(
'lastupdatedby' => $user->data()->id,
'filenumber' => Input::get('internal'),
'content' => Input::get('letterbody'),
);

$db->update('letters',$qid,$fields);
dump ($fields);
Redirect::to('lettersearch.php?msg=Letter+Updated!');
}


Any ideas what I am not seeing? There are no errors. If I goto the database, any changes made in any of the fields above do not get updated...
  Reply
#2
So here are the steps I would take.

I would start simple.

1. I would include the
Code:
users/init.php
instead of just the db class. There are other things you may need beyond just the db class. The most obvious thing is that you're using Input::get which is part of the input class which you haven't included.

Start there and see if that works.

2. If it doesn't, I would do something really simple just to make sure you're able to get SOMETHING into the DB. Without including the init, it probably doesn't even know the $user->data()-id, which is probably part of your problem, so once you've included the init, try doing

Code:
if ($updatestatus != 1) {
Code:
$db->insert('letters',['author'=>$user->data()->id]);
Code:
}

And make sure you're getting that into the db. If you need help beyond that, let me know.

  Reply
#3
Got it to work... silly me noticed now that this:

Code:
$fields = array(
Code:
‘lastupdatedby’ => $user->data()->id,


was actually suppose to be:

Code:
$fields = array(
Code:
‘lasteditedby’ => $user->data()->id,


So in essence I has the wrong name for the DB field...

Thanks for your help buddy... Much appreciated Smile
  Reply
#4
Yep. No problem. I wish there was a better way to get feedback from PDO when a field name is wrong, but it doesn't seem to give that info.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)