Fork me on GitHub
Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

- 2 2.5 2.6 3.0 4 6 2013 Abuse adslight Android AntiHarvesting AntiMalUser AntiSpam Apple Battlefield billige Blocks Bootstrap Captcha cell cent chronolabs CHUNG content CĂN demo docek download Dresses evden eve facebook Fat floor Food for free Gateway Google Guide herre Home Honeypot HP html5 Human HỘ IP iPhone jQuery List log Loss mobile module modules Monster new newbb news NHÀ online PARK phone PHP Prevention profile project Protector publisher Rapid RESIDENCE responsive review Rights rmcommon Room security Sentry site Smartphone Smarty Spam Studio tag tags tdmcreate template The Theme themes User userlog web weight xoops Xortify

New Users

Registering user

# 137305

bobop

Welcome to XOOPS!

Forum Index


Board index » All Posts (Mamba)

Bottom   Previous Topic   Next Topic

(1) 2 3 4 ... 599 »


#1 Posted on: 4/21 16:18 Re: Inserting multiple rows in database table
You need to go step by step backwards.

You want to assign a sanitized value of "table_nbfields" from $_REQUEST:

$table_nbfields TDMCreate_CleanVars($_REQUEST'table_nbfields');

But "table_nbfields" is not there. So you need to find out why it is not there, by finding the place where you are setting up this variable to "get" or "post".

The logic errors are the worst, because the syntax might be correct, and you won't get any PHP errors or warnings, but the result is still wrong. So go back through your logic step by step, set up breakpoints on the way to make sure that the variable is still there, and with the correct value. Then move to the next step...

This is one of the best and most funny pictures about debugging:

Resized Image


Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#2 Posted on: 4/21 15:47 Re: Inserting multiple rows in database table
Quote:
but I think we should Work it yet to find a solution.

As I suggested earlier, the best way to see what is wrong is to debug it, i.e. to set a breakpoint and check the status of the variables. Then you can see if your logic is correct and you have what you expect.

That's what I did, and it seems that your issue is that the "$table_nbfields" variable is empty at the point when you get to this code:

if ($table_nbfields 0) {
    
$datas = array();
    for( 
$i 0$i $table_nbfields$i++ ) {
        
$datas[] = array('field_mid' => $table_mid[$i],
                        
'field_tid' => $table_id[$i],
                        
'field_numb' => $table_nbfields[$i],
                        
'field_name' => $_POST['field_name'][$i],
                        
'field_type' => $_POST['field_type'][$i],
                        
'field_value' => $_POST['field_value'][$i],
                        
'field_attribute' => $_POST['field_attribute'][$i],
                        
'field_null' => $_POST['field_null'][$i],
                        
'field_default' => $_POST['field_default'][$i],
                        
'field_key' => $_POST['field_key'][$i],
                        
'field_autoincrement' => (($_REQUEST['field_autoincrement'][$i] == 1) ? '1' '0'),
                        
'field_element' => $_POST['field_element'][$i],
                        
'field_inlist' => (($_REQUEST['field_inlist'][$i] == 1) ? '1' '0'),
                        
'field_inform' => (($_REQUEST['field_inform'][$i] == 1) ? '1' '0'),
                        
'field_admin' => (($_REQUEST['field_admin'][$i] == 1) ? '1' '0'),
                        
'field_user' => (($_REQUEST['field_user'][$i] == 1) ? '1' '0'),
                        
'field_block' => (($_REQUEST['field_block'][$i] == 1) ? '1' '0'),
                        
'field_main' => (($i == $_REQUEST['field_main']) ? '1' '0'),
                        
'field_search' =>  (($_REQUEST['field_search'][$i] == 1) ? '1' '0'),
                        
'field_required' => (($_REQUEST['field_required'][$i] == 1) ? '1' '0')
                        );
    }
    foreach (
$datas as $value) {
        
$obj->setVars$value );
        
$fieldsHandler->insert($obj);
    }
}


so this:

if ($table_nbfields 0)

will never be true and you will never get to the code that you have shown us. And of course, you will never be able to test any changes you are making to it.

You define the variable as:
$table_nbfields TDMCreate_CleanVars($_REQUEST'table_nbfields');

But there is no variable of this name in the $_REQUEST.

There is the "field_numb", which seems to be the one that you're should be using.
Fix that, and then you'll be able to see if the whole array issue is working or not.

Always check your logic to make sure that you are getting what you expect to get, and that's why tools like PHPUnit are so helpful

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#3 Posted on: 4/21 15:16 Re: Inserting multiple rows in database table
Quote:
Meanwhile, I found some very interesting tools:

http://marcelog.github.io/articles/ci ... ntegration_php_phing.html

We've been using them already in the development of XOOPS 2.6.0, thanks to hard work by Alain91. See this news and look for the part about Jenkins.

And you and I had many emails about testing tools like PHPUnit and Sahi

But there are new tools that we're starting to use, and there will be soon a separate article about it

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#4 Posted on: 4/21 12:07 Re: Inserting multiple rows in database table
Quote:
You can also accomplish this by changing the following line:
$datas = array('field_mid' => $table_mid[$i],

with:
$datas[] = array('field_mid' => $table_mid[$i],

Yep, that was I was looking for:

$datas[] = array('field_mid' => $table_mid[$i],

Thanks guys for providing the fix for it. Hopefully Timgno can use it now...

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#5 Posted on: 4/19 14:54 Re: Inserting multiple rows in database table
Quote:
I'm not getting any syntax error, so I'll have to use other tools to check

Very often syntax is not the issue, but the logic in our thinking....

Just set breaks in your debugger, and compare the values there with what you expect. I am sure that very quickly you'll find a bug in your logic

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#6 Posted on: 4/19 10:39 Re: Inserting multiple rows in database table
Did you try to debug it?

I am not sure I understand the code. You declare the datas as an array, but you don't populate it as an array, and then you try to use it as an array when you populate the DB

Shouldn't it be something like:

$datas[$i] = array('field_mid' => $table_mid[$i],


Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#7 Posted on: 4/19 7:41 Re: Inserting multiple rows in database table
Quote:
Unfortunately it does not work

What doesn't work? What errors are you getting?

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#8 Posted on: 4/19 4:50 Re: Inserting multiple rows in database table
Why? What would be the "use case" for it?

You can currently create an array, and then run a loop like "foreach" and insert each element into the DB.

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#9 Posted on: 4/15 15:29 Re: transfer 2.5 a 2.5.6 bug
You should be able to upgrade from XOOPS 2.5.0 to XOOPS 2.5.6 without any problems. Just follow the instructions...

If something is not clear and you have question, please ask here and we'll try to help...

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum


#10 Posted on: 4/15 15:26 Re: WF-Downloads 3.23 RC
Quote:
It is possible to add support for XOOPS 2.5.6?

I am pretty sure that WF-Downloads 3.23 will be released after XOOPS 2.5.7, so there should be no problem to first update to XOOPS 2.5.7, and then install WF-Downloads.

Top


Please support XOOPS & DONATE
Use 2.5.6 | Debugging | Requests | Bugs
Mamba
Moderator
Moderator
Joined:
2004/4/23 13:58
From Ohio, USA
Group:
Webmaster
Registered Users
Designer Group
Posts: 7841
(Show More) (Show Less)
Topic | Forum



Top
(1) 2 3 4 ... 599 »



[Advanced Search]