The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
Running Update Query - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Off-topic Discussions (https://userspice.com/forums/forumdisplay.php?fid=10)
+--- Thread: Running Update Query (/showthread.php?tid=381)

Pages: 1 2 3 4


Running Update Query - Brandin - 12-03-2016

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!


Running Update Query - Brandin - 12-03-2016

I posted this on HasteBin since it went crazy on here:
http://hastebin.com/ehefapokas.php


Running Update Query - mudmin - 12-19-2016

I missed this one. I was on vacation. Did you get it figured out?


Running Update Query - Brandin - 12-19-2016

I did - I'll pull the code to let you know what I did later today. Hope you enjoyed your vacation!


Running Update Query - Brandin - 12-22-2016

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.


Running Update Query - mudmin - 12-22-2016

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.


Running Update Query - Brandin - 12-26-2016

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?


Running Update Query - mudmin - 12-28-2016

Can you pastebin the latest version of this code and I can figure it out for you?


Running Update Query - Brandin - 12-28-2016

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.


Running Update Query - mudmin - 12-28-2016

So just double checking...did you modify the db class?