Welcome Guest, Not a member yet? Register   Sign In
Problem with application after moving from local to hosting server
#11

[eluser]marcin_koss[/eluser]
I checked the app on a different hosting account(the same hosting provider). It behave the same way. Unfortunately I don't have access to hosting accounts from different provider.

The connection error happens when the array with the order items is being updated.
Below is the code that updates the order session.

Code:
$this->order = $this->session->userdata('order'); //saving order content to the array
        
        if(isset($_POST['submitted'])) {
        
            $order_array = $this->session->userdata('order');

            foreach($this->input->post('qty') as $k => $v) {
                $id = (int)$k;
                $qty = (int)$v;
                
                if (($qty == 0) || empty($qty)) { // delete product
                    unset($order_array[$id]);
                    }
                if ($qty > 0) {

                    $order_array[$id] = $qty;    
                }
            }
            $this->session->set_userdata('order', $order_array);

            $this->order = $this->session->userdata('order'); // Updated array is saved again to the session
        }

The already generated form that triggers the controller

Code:
<form action="http://www.zywiecshop.com/amtec_online2/index.php/orders/order_summary" method="post">

<table border="1" cellpadding="0" cellspacing="0" class="product_table">
<tr>
<th>No</th><th>Product Name</th><th>Qty</th></tr>

<tr>
<td>7</td><td>Product 1</td><td>&lt;input type="text" name="qty[7]" value="0" size="3"  /&gt;&lt;/td></tr>
<tr>
<td>20</td><td>Product 2</td><td>&lt;input type="text" name="qty[20]" value="0" size="3"  /&gt;&lt;/td></tr>
<tr>
<td>25</td><td>Product 3</td><td>&lt;input type="text" name="qty[25]" value="0" size="3"  /&gt;&lt;/td></tr>
<tr>
<td>18</td><td>Product 4</td><td>&lt;input type="text" name="qty[18]" value="0" size="3"  /&gt;&lt;/td></tr>
<tr>
<td>28</td><td>Product 5</td><td>&lt;input type="text" name="qty[28]" value="0" size="3"  /&gt;&lt;/td></tr>

</table>
&lt;input type="hidden" name="submitted" value="TRUE" /&gt;
&lt;input name="submitted" type="submit" value=" Go to order summary" alt="View Order" /&gt;
&lt;/form&gt;
#12

[eluser]vitoco[/eluser]
Try this

Code:
// ERROR REPORTING
        error_reporting( E_ALL );
        // IS THIS NECCESARY ???
        $this->order = $this->session->userdata('order'); //saving order content to the array ..???
        
        if(isset($_POST['submitted']))
        {
            //
            $order_array = $this->session->userdata('order');

            foreach($this->input->post('qty') as $k => $v)
            {
                $id = (int)$k;
                $qty_ = (int)$v;
                
                if ( ($qty_ == 0) OR ($qty_ < 0) )
                {
                    // delete product if exists
                    if( isset( $order_array[$id] ) )
                    {
                        unset( $order_array[$id] );
                    }
                }
                else
                {
                    //
                    $order_array[$id] = $qty_;    
                }
            }
            //
            $this->session->set_userdata('order', $order_array );
        }
#13

[eluser]vitoco[/eluser]
I saw something that it's maybe a problem, the index in the post array is 'qty', so if the php configuration has GLOBALS = on, in the first cicle inside the foreach


Code:
.....
    foreach($this->input->post('qty') as $k => $v)
    {
       $id = (int)$k;
       // IF GLOBAL IS ON , maybe the array is set to int...$qty ~ $_POST['qty']
       // SO CHANGE THE VARIABLE NAME TO SOMETHING ELSE AND TRY AGAIN..
       $qty = (int)$v;
.....

Saludos
#14

[eluser]marcin_koss[/eluser]
I'm sorry vitoco I don't quite understand what you want me to do. Which variable name you want me to change?
#15

[eluser]benurv[/eluser]
also enable (php.ini) errors, maybe a php error is causing this, with error logging disabled you wont see them.
it gives me an error 101, wich is a connection reset, sometimes caused by php functions not available or so, are you on php 5 ?
#16

[eluser]vitoco[/eluser]
Code:
// ERROR REPORTING
        error_reporting( E_ALL );
        // IS THIS NECCESARY ???
        $this->order = $this->session->userdata('order'); //saving order content to the array ..???
        
        if(isset($_POST['submitted']))
        {
            //
            $order_array = $this->session->userdata('order');

            foreach($this->input->post('qty') as $k => $v)
            {
                $id = (int)$k;
                $qty_ = (int)$v;
                
                if ( ($qty_ == 0) OR ($qty_ < 0) )
                {
                    // delete product if exists
                    if( isset( $order_array[$id] ) )
                    {
                        unset( $order_array[$id] );
                    }
                }
                else
                {
                    //
                    $order_array[$id] = $qty_;    
                }
            }
            //
            $this->session->set_userdata('order', $order_array );
        }
#17

[eluser]marcin_koss[/eluser]
[quote author="benurv" date="1274672240"]also enable (php.ini) errors, maybe a php error is causing this, with error logging disabled you wont see them.
it gives me an error 101, wich is a connection reset, sometimes caused by php functions not available or so, are you on php 5 ?[/quote]

Yes I'm on PHP 5 and error_reporting is on E_ALL

Vitoco: I have added the changes you suggested but the connection still gets reset.
Additionally I noticed that when I click on "Reset Session" which basically calls controller that unsets all the sessions besides the user session, connection gets reset as well.

Today I tested the application on my other machine with linux with xampp installed and everything worked flawlessly.
#18

[eluser]marcin_koss[/eluser]
...Coming back with some findings and resolution.

I finally tested the code on a different hosting server. It worked flawlessly!

I started digging again and for some reason I had the hunch that the sessions are the ones causing a problem on my client's server.

I have replaced all the CI sessions with native PHP sessions. Uploaded the code to the server and this time there was no reset connections!

Still have no idea what exactly was causing this server response.




Theme © iAndrew 2016 - Forum software by © MyBB