The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.18 (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
Running Update Query
#1
Hey!

I am using the UserSpice pages in many ways, and one of them is a migration tool. Basically, I have a list of categories, and if I migrate the category number to be another number, I also want to update all of the templates with that category number, to the new one. Currently, I am using the default function from the
Code:
admin_user.php
page that I just modified to my good, and I have this:

<pre>
Code:
//Update catnum

    if ($number != $_POST['number']){
       $number = Input::get("number");

      $fields=array('number'=>$number);
      $validation->check($_POST,array(
        'number' => array(
          'display' => 'Number',
          'required' => true,
          'min' => 1,
          'max' => 3
        )
      ));
    if($validation->passed()){
      $db->update('categories',$id,$fields);
      $successes[] = "Sort Updated";
</pre>


But what I need to do is also update the
Code:
templates
table
Code:
WHERE category=
the new
Code:
$number
I have set.

If you could help with the
Code:
$db->
function for this, I would be VERY appreciative Smile

Thanks again!
  Reply
#2
I posted this on HasteBin since it went crazy on here:
http://hastebin.com/ehefapokas.php
  Reply
#3
I missed this one. I was on vacation. Did you get it figured out?
  Reply
#4
I did - I'll pull the code to let you know what I did later today. Hope you enjoyed your vacation!
  Reply
#5
Now when I am running the update query this happens:

Warning: Invalid argument supplied for foreach() in /home/aircentralized/public_html/boss/users/classes/DB.php on line 50

Warning: Invalid argument supplied for foreach() in /home/aircentralized/public_html/boss/users/classes/DB.php on line 50

Line 50 is:
Code:
foreach ($params as $param) {
What does parms have to do with anything when I'm not calling for parms?

Thanks.
  Reply
#6
PHP didn't give you the most helpful error there. That error is part of the db->query method, so there is a problem with one of your queries. Go through any time you did any db queries on that page and see if there are any errors...

If you're kind of lost on where you messed up, just put

die();

after a query (starting from the top of the page) and reload the page. If you don't get that error, remove that die and put it after the next one.

Once you get the error, the query before the die is the one that is causing you a problem.
  Reply
#7
Hey mudmin,

I've tried doing this but it ends up stopping the page from loading because I'm using die(); in queries that load the page. This only happens when I actually perform an update, so it seems as if is something to do with the update query, but this is the same query from the default UserSpice pages, just modified for this purpose (only change the update values and table and stuff). It occurs on every page after I perform an update function.

Thoughts?
  Reply
#8
Can you pastebin the latest version of this code and I can figure it out for you?
  Reply
#9
Code:
templatesreqedit.php
https://hastebin.com/owoxawuyab.xml

This performs an update, and then gives me the error above, which is linked to the DB.php file which is here:
https://hastebin.com/ikoyugutiz.xml

Excuse this mixed use of mysqli queries and PDO lmao - I'm still trying to convert all of my stuff to PDO.
  Reply
#10
So just double checking...did you modify the db class?
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)