tags:

views:

76

answers:

1

I'm trying to transfer a site from one hosting company to another. I was using 000webhost until the client had hosting and a domain. Now that the client has their domain and hosting, using FatCow.com, I can not for the life of me, debug my PHP code. I'm not getting any errors. I have a successful DB connection. If you procedurally display data, it works, but when I try to use my original objects, something is breaking and just returns "0:". I have all errors on.

On old server where the site worked:

PHP Version 5.2.11

MySQL Version: 5.0.81

On new server where I get the "0:":

PHP Version 5.2.12

MySQL Version 5.0.32

I've setup a test page to test just the output of the variables with the DB connection.

Below is my code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
try
  {
   $link = mysql_connect('connectionstring', 'username', 'password'); 
  if (!$link) { 
      die('Could not connect: ' . mysql_error()); 
  } 
  else{
  $db = mysql_select_db('a8210422_lit'); 
  }
  if($db){



     include_once('admin/classes/clsPOW.php');
     include_once('admin/classes/clsProviders.php');

     $pow = new POW();
     $prov = new Providers();

     $new = $pow->getNew();

     $newAr = $new->val();

     $get = $prov->getAll($newAr['providerId']);

     $getAr = $get->val();

     $img = $getAr['image'];
     $name = $getAr['provider'];
     $desc = $getAr['description'];
     $zip = $getAr['zip'];
     $web = $getAr['link'];
     if($zip==0){
      $zip = "Unavailable"; 
     }

    print_r($getAr);



  }
  else{
   print 'fail!'; 
  }
    }

//catch exception
catch(Exception $e)
  {
  echo 'Message: ' .$e->getMessage();
  }



?>

//Class POW

require_once('clsSql.php');
require_once('clsResult.php');
include_once('/hermes/web07/b1323/moo.madisoncountyliterac/assets/includes/db.php');    
class POW{
    public function getNew(){
        //instantiate the sql class
        $SQL=new sql();                     
        //Run a query - Result is automatically stored in the class

        $sel = "SELECT providerId
                FROM litProviders
                WHERE image != ''
                ORDER BY RAND()
                LIMIT 1";

        $q=$SQL->query($sel);

        return $q;
    }


}

//Class Providers

require_once('clsSql.php');
require_once('clsResult.php');
include_once('/hermes/web07/b1323/moo.madisoncountyliterac/assets/includes/db.php');
class Providers{    
    public function getAll($where=""){
        if($where == ""){
            $getAllQuery = "SELECT * FROM litProviders";
        }
        else{
            $getAllQuery = "SELECT * FROM litProviders WHERE providerId = '".$where."'";
        }       
        //instantiate the sql class
        $SQL=new sql();                 
        //Run a query - Result is automatically stored in the class
        $q=$SQL->query($getAllQuery);
        return $q;
    }

    public function submit($id="", $provider, $description, $zip, $image, $link){

        if($id != ""){
            //update
            $query = "UPDATE litProviders SET provider = '".$provider."', description = '".$description."', zip = '".$zip."', image = '".$image."', link = '".$link."'
                      WHERE providerId = '".$id."' ";

            $message = "The provider has been updated.";
        }
        else{
            //insert    
            $newid = md5(uniqid());

            $query = "INSERT INTO litProviders 
                      VALUES ('".$newid."','".$provider."','".$description."','".$zip."','".$image."', '".$link."')";

            $message = "You have added a new provider.";                          
        }
        //instantiate the sql class
        $SQL=new sql();                 
        //Run a query - Result is automatically stored in the class
        $q=$SQL->query($query);

        return $message;

    }
    public function delete($id=""){
        if($id !=""){
            $delQuery = "DELETE FROM litProviders WHERE providerId = '".$id."'";    
            //instantiate the sql class
            $SQL=new sql();                     
            //Run a query - Result is automatically stored in the class
            $q=$SQL->query($delQuery);
            if($q){
                return true;    
            }
            else{
                return false;   
            }
        }
        else{
            return "No ID was provided for deletion.";  
        }
    }
}
+1  A: 

It's not useful to print variables if you don't print something besides them, to recognize them.

You should instead

print_r(array(
    "thing" => $thing,
    "stuff" => $stuff,
    "dwarf" => $dwarf,
));
Lo'oris
I agree. I was a little ticked off and began forgetting some basic principles. I changed it.
Michael Stone
and now what do you get as output?
Lo'oris
Nothing. it didn't make any impact. I'm not getting a result set.
Michael Stone
If I procedurally display the data, it works. So the connection is good.
Michael Stone
try to echo something before the includes
Lo'oris
Echoing was a success before the includes.
Michael Stone
this obviously means the problem is in the included files and not in the posted code
Lo'oris
I added the two included files to see if anything pops out at you. clsSQL is a generic class that has php SQL functions.
Michael Stone