2

I try to submit some data from view to model via controller, but it won't do anything.

In the view i have a form which submit some data to controller

The Controller:

if(isset($POST['CNE']))
        {
            $Craftname=$_POST['Str'].$_POST['Dex'].$_POST['Rec'].$_POST['Int'].$_POST['Wis'].$_POST['Luc'];
            $Craftname.=$_POST['HP'].$_POST['MP'].$_POST['SP'].$_POST['Enchant'];
            $update = array(
                'ItemID' => $_POST['ItemID'],
                'Type' => $_POST['Type'],
                'TypeID' => $_POST['TypeID'],
                'Gem1' => $_POST['Gem1'],
                'Gem2' => $_POST['Gem2'],
                'Gem3' => $_POST['Gem3'],
                'Gem4' => $_POST['Gem4'],
                'Gem5' => $_POST['Gem5'],
                'Gem6' => $_POST['Gem6'],
                'Craftname' => $Craftname,
                'Count' => $_POST['Count']
            );

            $this->item_edit->updateItem($update, $_POST['ItemUID']);
        }

And the Model

function updateItem($update, $uid)
{
    $this->db->where('ItemUID', $uid);
    $this->db->update('PS_GameData.dbo.CharItems' ,$update);        
}

On submit the view displays the posted data as follows

Name    Value
ItemName    Dreamy Vallum Helmet
ItemUID 4513324807718567936
ItemID  16052
Type    16
TypeID  52
Gem1    7
Gem2    0
Gem3    0
Gem4    0
Gem5    0
Gem6    0
Str 06
Dex 00
Rec 00
Int 00
Wis 05
Luc 04
HP  00
MP  00
SP  00
Enchant 00
Count   1

But the data won't be submitted to the database aswell.. on refresh the data displays as was before. It won't prompt me with any errors at all. Maybe someone can help me figure out the issue.

  • What is the error the system creates when trying to update that record? Most debugging is about finding the error. My bet is your columns don't accept null values and some of your post data isn't set. – Mikel Bitson Nov 11 '15 at 21:58
  • The system doesn't prompt any error, neither Firebug or other debuggers. The table indeed doesn't accept NULL values but none of the above are null as they use default 0 and 00, i used this method with mssql driver and just php and it works but inside codeigniter (MVC patern) i am quite new and maybe i do something wrong in the query, as before this POST take place there are 2 more posts, a userid and itemid and uses the same method, they works but this form doesn't. – Daniel Treica Nov 12 '15 at 07:24
  • 1
    Firebug is for debugging client-side code, not PHP. Step one to fixing your issue would be to get error reporting working.http://stackoverflow.com/questions/5911964/cannot-get-php-display-errors-enabled – Mikel Bitson Nov 12 '15 at 12:55

2 Answers2

0

at first take care about case sensitive whereas if all fields in database are small, all array keys should be small and so on

also you should only write table name

  • All the characters matches the database structure they uses capitalization of characters of column names, and i have checked them and they indeed match. For the table name i can't use only the table name because i have multiple databases which has information and i must point it in the right direction. – Daniel Treica Nov 12 '15 at 07:49
0

I have fixed it by adding the if isset statement in a separate function inside the controller and set in form action="controller/function_name" and it works now.