• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI+GoCart: Form submission works in localhost but NOT on live server

#1
Hi all, 

I've been searching high and low and pulling my hear out over this issue. No one at StackOverflow has been able to help so far. 

I'm using CodeIgniter + GoCart for a project right now and I've had one problem after another migrating from my localhost dev server to the Dreamhost shared hosting servers (never in a million years would I use them after the experiences I've had over the last week of nightmares!). 

The latest problem is that forms (login, registration, search, add to cart) do not submit on the live server but they do work perfectly on my localhost server. When I press "login" (admin and normal) or register, the pages just refresh. When I click "search," I'm taken to http://example.com/search (incomplete URL, see below) and I get an error about not providing a full search query. When I press "add to cart," things just load forever and nothing happens. 

I've checked the database and it's not that. I've also checked CI session storage  and I don't THINK it's that. At any rate, when I try to register, no new rows are created in the database, so something's stopping it before then. 

When I search for something on the local server, I am taken to a hashed URL like this: 
Code:
http://localhost:8080/example.com/search/45d20b1d2cc2d52e74b3cbf1750a2e31/name/ASC/0

So I copied the URL after /search and tried to see what http://example.com/search/45d20b1d2cc2d5...name/ASC/0 would do. 

As it turns out, I get an error: 
Code:
A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/Search.php

Line Number: 32

Backtrace:

File: /home/user/example.com/application/modules/search/models/Search.php
Line: 32
Function: _error_handler

File: /home/user/example.com/application/modules/search/controllers/Search.php
Line: 49
Function: getTerm

File: /home/user/example.com/application/controllers/Bootstrap.php
Line: 206
Function: call_user_func_array

File: /home/user/example.com/index.php
Line: 294
Function: require_once
I looked at each file at the lines indicated but could not figure out what the issue may be... 
Boostrap.php (line 206 = try{ ... call_user_func_array() } ): 
PHP Code:
// lets run the routes
        
$match $router->match();

        
// call a closure
        
if( $match && is_callable$match['target'] ) ) {
            
call_user_func_array$match['target'], $match['params'] );
        }

        
// parse a string and call it
        
elseif($match && is_string($match['target']))
        {
            
$target explode('#'$match['target']);

            try {
                
$class = new $target[0];
                
call_user_func_array([$class$target[1]], $match['params']);

            } catch(
Exception $e) {
                
var_dump($e);
                
throw_404();
            }
        }

        
// throw a 404 error
        
else
        {
            
throw_404(); 

Search.php (line 49 = $term=\CI:: Search()->getTerm() ): 
PHP Code:
\CI::load()->model('Search');

 
       //check to see if we have a search term
 
       if(!$code)
 
       {
 
           //if the term is in post, save it to the db and give me a reference
 
           $term = \CI::input()->post('term'true);
 
           if(empty($term))
 
           {
 
               //if there is still no search term throw an error
 
               $data['error'] = lang('search_error');
 
               $this->view('search_error'$data);
 
               return;
 
           }
 
           else
            
{
 
               $code = \CI::Search()->recordTerm($term);

 
               // no code? redirect so we can have the code in place for the sorting.
 
               // I know this isn't the best way...
 
               redirect('search/'.$code.'/'.$sort.'/'.$dir.'/'.$page);
 
           }
 
       }
 
       else
        
{
 
           //if we have the md5 string, get the term
 
           $term = \CI::Search()->getTerm($code);
 
       

Search.php (model, line 32 = getTerm(){ ... return...} ): 
PHP Code:
Class Search extends CI_Model
{

    function recordTerm($term)
    {
        $code   md5($term);
        CI::db()->where('code'$code);
        $exists CI::db()->count_all_results('search');
        if ($exists 1)
        {
            CI::db()->insert('search', array('code'=>$code'term'=>$term));
        }
        return $code;
    }
    
    
function getTerm($code)
    {
        CI::db()->select('term');
        $result CI::db()->get_where('search', array('code'=>$code));
        $result $result->row();
        return $result->term;
    }


I will happily provide as much code as required for someone to help! I have no idea what it is doing and this issue is literally preventing the launch of the site! 
I've even added added a special user/password for you guys to access the site: 
http://kitkittlegallery.com 
u: visitor
pw: visitor 
I shower those who can help in appreciation!
Reply

#2
Bump, in the hopes that someone will be able to help?
Reply

#3
UPDATE: The solution to this problem was not changing any code. Instead, I realized that Dreamhost shared hosting was forcing www. before all URLs. I disabled this so only http:// would work (www. is redirected to http:// now), and the code all started to work.
Reply

#4
(12-03-2015, 08:35 AM)zwellstood Wrote: UPDATE: The solution to this problem was not changing any code. Instead, I realized that Dreamhost shared hosting was forcing www. before all URLs. I disabled this so only http:// would work (www. is redirected to http:// now), and the code all started to work.

how you did that can you elaborate please.....
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.