0

I have a storelocator for my client's website that uses a database to get all the information of the stores. This store locator works perfectly on my desktop and on my laptop local servers (localhost), but once I upload everything to my test site the store locator won't work. In a file called locate.php I include a file/class called store.php, when I go to the locate.php file on my localserver I only get notices which aren't a big deal.

enter image description here

When I go to my site, this error appears.

enter image description here

In the locate.php I also include a file called defines.php which has the information required to access the db (host, username, password, dbname). At first I thougt it could be a GoDaddy problem but I've used localhost and my website IP as the host, deleted and reuploaded the database and nothing seems to work.

Here are the files I've mentioned in this thread.

locate.php

include_once("./defines.php");

include_once("./class/store.php");

function vectorLength($x,$y){
    return sqrt(($x*$x)+($y*$y));
}

$R=6378.1;
$count=0;

$total = $_GET['total'];


//$stores[$total];

//$distances[$total];

$lat=$_GET['lat'];
$lng=$_GET['lng'];

$maxdist=0;
$maxid=-1;

//first filter for 100km radius (0.9 degrees on equator = 100km)
$verified_stores = getStores("status=".VERIFIED." AND latitude > '".($lat-0.9)."' AND latitude < '".($lat+0.9)."' AND longitude > '".($lng-0.9)."' AND longitude < '".($lng+0.9)."'",NULL,0,0);

for($i=0;$i<count($verified_stores);$i++){
    $clat = $verified_stores[$i]->latitude;
    $clng = $verified_stores[$i]->longitude;

    $dlat=$lat-$clat;
    $dlng=$lng-$clng;


    //second filter using haversine distance
    $dLat=deg2rad($dlat);
    $dLng=deg2rad($dlng);

    //haversine calculations
    $a = pow(sin($dLat/2),2)+cos(deg2rad($lat)) * cos(deg2rad($clat))*pow(sin($dLng/2),2);

    $c = 2 * asin(sqrt($a));

    $d = $R*$c;

    if($d>$_GET['radius']) continue;

    if($count<$total){
        //keep track of farthest distance
        if($maxdist<$d){
            $maxdist=$d;
            $maxid=$count;
        }

        //insert into list of not full
        $stores[$count]=$verified_stores[$i]->storeID;

        $distances[$count]=$d;
        $count++;
    }
    else{
        //scan distances
        if($d<$maxdist){
            //replace farthest store
            $stores[$maxid]=$verified_stores[$i]->storeID;
            $distances[$maxid]=$d;

            $maxdist=0;

            //find next maxid
            for($j=0;$j<$total;$j++){
                if($maxdist<$distances[$j]){
                    $maxdist=$distances[$j];
                    $maxid=$j;
                }
            }
        }
    }
}

//bubble sort stores

$total=$count;
for($i=0;$i<$total-1;$i++){
    $swapped=false;
    for($j=$i+1;$j<$total;$j++){
        if($distances[$i]>$distances[$j]){
            //swap $i and $j
            $temp=$distances[$i];
            $distances[$i]=$distances[$j];
            $distances[$j]=$temp;

            $temp=$stores[$i];
            $stores[$i]=$stores[$j];
            $stores[$j]=$temp;
            $swapped=true;
        }
    }
}

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "\n<LOCATIONS>\n";


for($i=0;$i<$total;$i++){
    $store = getStore($stores[$i]);

    $clat=$store->latitude;
    $clng=$store->longitude;

    $dLat=deg2rad($lat-$clat);
    $dLng=deg2rad($lng-$clng);

    //haversine calculations
    $a = pow(sin($dLat/2),2)+cos(deg2rad($lat)) * cos(deg2rad($clat))*pow(sin($dLng/2),2);

    $c = 2 * asin(sqrt($a));

    $d = $R*$c;

    $webpage = $store->webpage;
    if(strlen($webpage)==0) $webpage="<![CDATA[&nbsp;]]>";

    echo "<STORE>\n";
    echo "<DIST>$d</DIST>\n";   
    echo "<NAME><![CDATA[".htmlspecialchars($store->name)."]]></NAME>\n";
    echo "<ADDR>".htmlspecialchars($store->address)."</ADDR>\n";
    echo "<PHONE>".htmlspecialchars($store->phone)."</PHONE>\n";
    echo "<WEBPAGE>$webpage</WEBPAGE>\n";
    echo "<LAT>$clat</LAT>\n";
    echo "<LNG>$clng</LNG>\n";
    echo "</STORE>\n";
}


echo "</LOCATIONS>\n";

?>

store.php

<?php

class Store{
    public $storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated;

    public function __construct($storeID=NULL,$name=NULL,$contact=NULL,$address=NULL,$phone=NULL,$fax=NULL,$email=NULL,$webpage=NULL,$latitude=0,$longitude=0,$status=0,$created=NULL,$updated=NULL){
        $this->storeID=$storeID;
        $this->name=$name;
        $this->contact=$contact;
        $this->address=$address;
        $this->phone=$phone;
        $this->fax=$fax;
        $this->email=$email;
        $this->webpage=$webpage;
        $this->latitude=$latitude;
        $this->longitude=$longitude;
        $this->status=$status;
        //$this->enabled=$enabled;
        $this->created=$created;
        $this->updated=$updated;
    }
    public function toString(){
        $s="StoreID: ".$this->storeID."<br/>";
        $s.="Name: ".$this->name."<br/>";
        $s.="Contact: ".$this->contact."<br/>";
        $s.="Address: ".$this->address."<br/>";
        $s.="Phone: ".$this->phone."<br/>";
        $s.="Fax: ".$this->fax."<br/>";
        $s.="E-mail: ".$this->email."<br/>";
        $s.="Webpage: ".$this->webpage."<br/>";
        $s.="Latitude: ".$this->latitude."<br/>";
        $s.="Longitude: ".$this->longitude."<br/>";
        $s.="Status: ".$this->status."<br/>";
        $s.="Created: ".$this->created."<br/>";
        $s.="Updated: ".$this->updated."<br/>";
        return $s;
    }
}

function restoreStore($id){updateStoreStatus($id,UNVERIFIED);}
function verifyStore($id){updateStoreStatus($id,VERIFIED);}
function unverifyStore($id){updateStoreStatus($id,UNVERIFIED);}
function trashStore($id){updateStoreStatus($id,RECYCLING_BIN);}
function updateStoreStatus($id,$status){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);
    $q=$db->prepare('UPDATE Stores SET status=?, updated=? WHERE storeID=?');
    $date=date("Y-m-d H:i:s");
    $q->bind_param("isi",$status,$date,$id);
    $q->execute();
    $q->close();
    return 1;
}
function emptyStores(){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);
    $q=$db->prepare('DELETE FROM Stores WHERE status='.RECYCLING_BIN);
    $q->execute();
    $q->close();    
    return 1;
}
function deleteStore($id){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);
    $q=$db->prepare('DELETE FROM Stores WHERE storeID=?');
    $q->bind_param("i",$id);
    $q->execute();
    $q->close();    
    return 1;
}

function insertStore($store){
    $db = new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);

    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }

    $store->created=date("Y-m-d H:i:s");        //overwrite dates
    $store->updated=$store->created;

    if($q = $db->prepare('INSERT INTO Stores (name,contact,address,phone,fax,email,webpage,latitude,longitude,status,created,updated) values (?,?,?,?,?,?,?,?,?,?,?,?)')){
        $q->bind_param("sssssssssiss",
            $store->name,
            $store->contact,
            $store->address,
            $store->phone,
            $store->fax,
            $store->email,
            $store->webpage,
            $store->latitude,
            $store->longitude,
            $store->status,
            $store->created,
            $store->updated);
        $q->execute();
        $q->close();
    }
    else{
        printf($db->errno);
        exit();
    }

    $q=$db->prepare('SELECT storeID FROM Stores WHERE name=? AND created=?');
    $q->bind_param("ss",$store->name,$store->created);
    $q->execute();
    $q->bind_result($sid);
    $q->fetch();
    $q->close();

    if(strlen($sid)>0) return $sid;
    else return ERROR_DEFAULT;
}


//PRE-CONDITION: email, password, billingID, groupID must exist
function updateStore($store){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);

    //BEGIN ERROR CHECKING -------------------------------

    //END ERROR CHECKING ---------------------------------

    $store->updated=date("Y-m-d H:i:s");        //overwrite dates

    $q=$db->prepare('UPDATE Stores SET name=?, contact=?, address=?, phone=?, fax=?, email=?, webpage=?, latitude=?, longitude=?, status=?, updated=? WHERE storeID=?');
    $q->bind_param("sssssssssisi", $store->name,$store->contact,$store->address,$store->phone,$store->fax,$store->email,$store->webpage,$store->latitude,$store->longitude, $store->status, $store->updated,$store->storeID);
    $q->execute();
    $q->close();

    $q=$db->prepare('SELECT storeID FROM Stores WHERE name=? AND created=?');
    $q->bind_param("ss",$store->username,$store->created);
    $q->execute();
    $q->bind_result($sid);
    $q->fetch();
    $q->close();

    if(strlen($sid)>0) return $sid;
    else return ERROR_DEFAULT;
}


function getStore($id){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);
    $q=$db->prepare('SELECT storeID,name,contact,address,phone,fax,email,webpage,latitude,longitude,status,created,updated FROM Stores WHERE storeID=?');
    $q->bind_param("i",$id);
    $q->execute();
    $q->bind_result($storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated);
    $s=NULL;
    if($q->fetch()){
        $s=new Store($storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated);
    }
    $q->close();    
    return $s;
}

function getStoreCount($filter=NULL){
    $db=new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);
    $sql='SELECT COUNT(*) FROM Stores';
    if($filter!=NULL) $sql.=" WHERE ".$filter;

    $q=$db->prepare($sql);
    $q->execute();
    $q->bind_result($count);
    $q->fetch();
    $q->close();    
    return $count;
}

function getStores($filter=NULL,$order=NULL,$start=0,$limit=10){
    $db = new mysqli(DB_HOST, DB_ADMIN, DB_PWORD, DB_NAMES);

    $sql='SELECT storeID,name,contact,address,phone,fax,email,webpage,latitude,longitude,status,created,updated FROM Stores';
    if($filter!=NULL) $sql.=" WHERE ".$filter;
    if($order!=NULL) $sql.=" ORDER BY ".$order;
    if($limit>0) $sql.=' LIMIT '.$start.','.$limit;

    $q=$db->prepare($sql);
    $q->execute();
    $q->bind_result($storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated);
    $s=NULL;
    while($q->fetch()){

        if($s==NULL) $s=array();
        $store=new Store($storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated);
        $s[]=$store;
    }
    $q->close();    
    return $s;
}

?>

defines.php

<?php
define("CHARSET","utf-8");
define("BASE_URL","http://MYURL/");
define("SITE_NAME","MY SITE Maps Manager");
define("SITE_TITLE","Default Title");
define("GOOGLE_ANALYTICS_TRACKER_ID","");
define("RECAPTCHA_PUBLIC_KEY","");
define("RECAPTCHA_PRIVATE_KEY","");

define("PRIVATE_KEY","");

define("RECYCLING_BIN",-1);
define("DEFAULT_STATUS",0);
define("VERIFIED",1);
define("UNVERIFIED",2);

define("ERROR_DEFAULT",-1);

define("DB_HOST","localhost");
define("DB_ADMIN","GODADDY_DBUSER");
define("DB_PWORD","MYPASSWORD");
define("DB_NAMES","DATABASENAME");
?>
Jay
  • 171
  • 3
  • 15
  • check with isset() in both local and live server – Niklesh Raut May 12 '16 at 07:29
  • The Server Error says that **$db has not been instantiated.** Like @Rishi rightly observed, you have to check that the Database Connection is OK I will repost a part of your Store class just for clarification... – Poiz May 12 '16 at 07:41
  • Try with the server ip instead of localhost, see if it works on the live server? also, did you echo your global vars and see if the correct values are there? – Ralph Melhem May 12 '16 at 07:47

1 Answers1

1

Seems like we've just run out of mysql[i] tricks.

ENTER PDO:

UPDATED WITH TABLE-NAME AS: stores

<?php

    // THIS IS ESSENTIALLY THE SAME STORE CLASS AS YOU HAD
    // EXCEPT THIS TIME WE CHANGED EVERYTHING CONNECTED WITH mysql[i]
    // IN OTHER WORDS; THIS IS THE PDO EQUIVALENT OF YOUR STORE CLASS:




    /***********************************************/
    /******    BEGIN STORE CLASS DEFINITION   ******/
    /***********************************************/
    class Store{
        public $storeID,$name,$contact,$address,$phone,$fax,$email,$webpage,$latitude,$longitude,$status,$created,$updated;

        //CREATE A STATIC PROPERTY TO HOLD YOUR DB-RESOURCE:
        /**@var PDO $db*/
        protected static $db;

        public function __construct($storeID=NULL,$name=NULL,$contact=NULL,$address=NULL,$phone=NULL,$fax=NULL,$email=NULL,$webpage=NULL,$latitude=0,$longitude=0,$status=0,$created=NULL,$updated=NULL){
            // JUST CALL THE DB CONNECTION METHOD ONCE AND USE THE HANDLE EVERYWHERE IN YOUR CODE LIKE SO:
            self::establishDBConnection();

            $this->storeID      = $storeID;
            $this->name         = $name;
            $this->contact      = $contact;
            $this->address      = $address;
            $this->phone        = $phone;
            $this->fax          = $fax;
            $this->email        = $email;
            $this->webpage      = $webpage;
            $this->latitude     = $latitude;
            $this->longitude    = $longitude;
            $this->status       = $status;
            $this->created      = $created;
            $this->updated      = $updated;
            //$this->enabled=$enabled;
        }

        // TRY PUTTING YOUR DATABASE CONNECTION LOGIC IN ONE METHOD FOR SIMPLICITY:
        public static function establishDBConnection() {
            try {
                if(static::$db){
                    return static::$db;
                }else{
                    static::$db = new PDO('mysql:host='.DB_HOST.';dbname='. DB_NAMES,DB_ADMIN,DB_PWORD);
                    static::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                    return self::$db;
                }
            } catch (PDOException $e) {
                // IF THERE WAS AN ANY KIND OF CONNECTION ERROR, "DIE IT OUT" TO THE OUTPUT STREAM:
                die($e->getMessage());
            }
        }

        public function toString(){
            $s="StoreID: ".$this->storeID."<br/>";
            $s.="Name: ".$this->name."<br/>";
            $s.="Contact: ".$this->contact."<br/>";
            $s.="Address: ".$this->address."<br/>";
            $s.="Phone: ".$this->phone."<br/>";
            $s.="Fax: ".$this->fax."<br/>";
            $s.="E-mail: ".$this->email."<br/>";
            $s.="Webpage: ".$this->webpage."<br/>";
            $s.="Latitude: ".$this->latitude."<br/>";
            $s.="Longitude: ".$this->longitude."<br/>";
            $s.="Status: ".$this->status."<br/>";
            $s.="Created: ".$this->created."<br/>";
            $s.="Updated: ".$this->updated."<br/>";
            return $s;
        }
    }
    /***********************************************/
    /*******    END STORE CLASS DEFINITION   *******/
    /***********************************************/



    function restoreStore($id){updateStoreStatus($id,UNVERIFIED);}

    function verifyStore($id){updateStoreStatus($id,VERIFIED);}

    function unverifyStore($id){updateStoreStatus($id,UNVERIFIED);}

    function trashStore($id){updateStoreStatus($id,RECYCLING_BIN);}

    function updateStoreStatus($id,$status){
        $db     = Store::establishDBConnection();
        $q      = $db->prepare('UPDATE stores SET status=:status, updated=:updated WHERE storeID=:storeID');
        $date   = date("Y-m-d H:i:s");
        $q->execute(array(
            'status'    => $status,
            'updated'   => $date,
            'storeID'   => $id,
        ));
        $q->execute();
        return 1;
    }

    function emptyStores(){
        $rcBin  = RECYCLING_BIN;
        $db     = Store::establishDBConnection();
        $q      = $db->prepare('DELETE FROM stores WHERE status=:rcBIN');
        $q->bindParam(':rcBIN', $rcBin);
        $q->execute();
        return 1;
    }

    function deleteStore($id){
        $db = Store::establishDBConnection();
        $q=$db->prepare('DELETE FROM stores WHERE storeID=:storeID');
        $q->bindParam(':storeID', $id);
        $q->execute();
        return 1;
    }

    function insertStore($store){
        $db             = Store::establishDBConnection();
        $store->created =date("Y-m-d H:i:s");        //overwrite dates
        $store->updated =$store->created;

        $sql            = 'INSERT INTO stores (name, contact, address, phone, fax, email, webpage, latitude, longitude, status, created, updated) ';
        $sql           .= 'values (:name, :contact, :address, :phone, :phone, :fax, :email, :webpage, :latitude, :longitude, :status, :created, :updated)';

        if($q = $db->prepare($sql)){
            $arrValues  = array(
                "name"          =>$store->name,
                "contact"       =>$store->contact,
                "address"       =>$store->address,
                "phone"         =>$store->phone,
                "fax"           =>$store->fax,
                "email"         =>$store->email,
                "webpage"       =>$store->webpage,
                "latitude"      =>$store->latitude,
                "longitude"     =>$store->longitude,
                "status"        =>$store->status,
                "created"       =>$store->created,
                "updated"       =>$store->updated
        );

            $q->execute($arrValues);
        }
        else{
            printf($db->errorCode());
            exit();
        }

        $q          = $db->prepare('SELECT storeID FROM stores WHERE name=:name AND created=:created');
        $q->bindParam(":name",      $store->name);
        $q->bindParam(":created",   $store->created);
        $objSID     = $q->fetch(PDO::FETCH_OBJ);

        if(strlen($objSID->storeID)>0) return $objSID->storeID;
        else return ERROR_DEFAULT;
    }


    //PRE-CONDITION: email, password, billingID, groupID must exist
    function updateStore($store){
        $db         = Store::establishDBConnection();

        //BEGIN ERROR CHECKING -------------------------------

        //END ERROR CHECKING ---------------------------------

        $store->updated=date("Y-m-d H:i:s");        //overwrite dates

        $sql        = 'UPDATE stores SET name=:name, contact=:contact, address=:address, phone=:phone, fax=:fax, email=:email, webpage=:webpage, latitude=:latitude, longitude=:longitude, status=:status, updated=:updated WHERE storeID=:storeID';
        $q          = $db->prepare($sql);

        $arrValues  = array(
            "name"          =>$store->name,
            "contact"       =>$store->contact,
            "address"       =>$store->address,
            "phone"         =>$store->phone,
            "fax"           =>$store->fax,
            "email"         =>$store->email,
            "webpage"       =>$store->webpage,
            "latitude"      =>$store->latitude,
            "longitude"     =>$store->longitude,
            "status"        =>$store->status,
            "created"       =>$store->created,
            "updated"       =>$store->updated,
            "storeID"       =>$store->storeID
        );

        $q->execute($arrValues);

        $q          = $db->prepare('SELECT storeID FROM stores WHERE name=:name AND created=:created');
        $q->bindParam(":name",      $store->username);
        $q->bindParam(":created",   $store->created);
        $objSID     = $q->fetch(PDO::FETCH_OBJ);

        if(strlen($objSID->storeID)>0) return $objSID->storeID;
        else return ERROR_DEFAULT;
    }

    function getStore($id){
        $db         = Store::establishDBConnection();
        $sql        = 'SELECT storeID, name, contact, address, phone, fax, email, webpagee, latitud, longitude, status, created, updated FROM stores WHERE storeID=:storeID';
        $q          = $db->prepare($sql);
        $q->bindParam(":storeID", $id);
        $q->execute();

        $storeObj   = $q->fetch(PDO::FETCH_OBJ);
        $s          = NULL;

        if($storeObj){
            $s      = new Store($storeObj->storeID, $storeObj->name, $storeObj->contact, $storeObj->address, $storeObj->phone, $storeObj->fax, $storeObj->email, $storeObj->webpage, $storeObj->latitude, $storeObj->longitude, $storeObj->status, $storeObj->created, $storeObj->updated);
        }
        return $s;
    }

    function getStoreCount($filter = NULL){
        $db         = Store::establishDBConnection();
        $sql        = 'SELECT COUNT(*) as count FROM stores';
        if($filter != NULL) $sql .= " WHERE " . $filter;

        $q          = $db->prepare($sql);
        $q->execute();
        $objCount   = $q->fetch(PDO::FETCH_OBJ);
        $count      = $objCount->count;
        return $count;
    }

    function getStores($filter = NULL, $order = NULL, $start = 0, $limit = 10){
        $db         = Store::establishDBConnection();
        $sql        ='SELECT storeID, name, contact, address, phone, fax, email, webpage, latitude, longitude, status, created, updated FROM stores ';
        if($filter != NULL) $sql .= " WHERE "   . $filter;
        if($order  != NULL) $sql .= " ORDER BY ". $order;
        if($limit > 0)      $sql .= ' LIMIT '   . $start .',' . $limit;

        $q          = $db->prepare($sql);
        $q->execute();
        $arrData    = $q->fetch(PDO::FETCH_ASSOC);
        $stores     = array();

        foreach($arrData as $intKey=>$objData){
            $store      = new Store($objData->storeID, $objData->name, $objData->contact, $objData->address, $objData->phone, $objData->fax, $objData->email, $objData->webpage, $objData->latitude, $objData->longitude, $objData->status, $objData->created, $objData->updated);
            $stores[]   = $store;
        }
        return $stores;
    }

?>
Poiz
  • 7,611
  • 2
  • 15
  • 17
  • This is the error that I get, any idea what's the problem? Fatal error: Cannot access self:: when no class scope is active in /home/MYPATH/maps/class/store.php on line 195 – Jay May 12 '16 at 08:37
  • @Josef I edited the Store Class again... try testing it one more time to see what you get. Keep me posted ;-) – Poiz May 12 '16 at 08:43
  • @Josef The Error was right. My Bad... I just updated the Store Class again. You may want to give it a go and see what you get... – Poiz May 12 '16 at 08:49
  • Still the same execute() fatal error but this time on line 199. @Poiz – Jay May 12 '16 at 08:56
  • **Good!!!** Yes.... LINE 199... I saw that you were ***executing the query on line 199 before binding the values***. The reverse should be the case. I updated the Class yet again. – Poiz May 12 '16 at 09:15
  • Still getting fatal errors @Poiz **Fatal error: Call to a member function bind_result() on a non-object in /homeMYPATH/maps/class/store.php on line 202** – Jay May 12 '16 at 17:57
  • @Josef There are some updates now. The Store Class now uses PDO for DB Transactions. Just check it out (if you will) and see what you get... ;-) And by the way; ***make sure your DEFINEs are visible to this Class*** – Poiz May 12 '16 at 19:27
  • That didn't work either, but I think we got the actual error (which I'm having a hard time to figure out) **Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bb_stores.Stores' doesn't exist' in /home/--/maps/class/store.php:233 Stack trace: #0 /home/--/maps/class/store.php(233): PDOStatement->execute() #1 /home/--/maps/locate.php(30): getStores('status=1 AND la...', NULL, 0, 0) #2 {main} thrown in /home/--/maps/class/store.php on line 233** – Jay May 12 '16 at 19:52
  • **Beautiful!** At least we know more ;-) PDO doesn't seem to find the Table called ***"Stores"*** Could you double check that the name of the Table is exactly ***Stores***? On the other hand, is ***the name of the Database*** **bb_stores**? – Poiz May 12 '16 at 20:01
  • In my server it is stores with lowercase **s**, is that the problem? http://i.imgur.com/QgL4OvL.png – Jay May 12 '16 at 20:05
  • **In most Unix/Linux System, Yes: Database Table names are case-sensitive** but not in windows... ( http://stackoverflow.com/questions/6134006/are-table-names-in-mysql-case-sensitive ). Anyways; I have now just changed the name of the Table to **stores**... If in the end everything works out fine; you owe me a Beer ;-) – Poiz May 12 '16 at 20:11
  • Yep, I'm paying that beer, only that the errors were solved but for some reason when I search for a store the answer I get is that there are no stores nearby, I think there's a problem to get the stores. – Jay May 12 '16 at 20:19
  • Which function are you calling? ***getStore($id)***? Or rather, which method is responsible for **searching the stores**? What is the search algorithm you are using to search for stores? – Poiz May 12 '16 at 20:22
  • Whoop, never mind, just figured out how to solve that, thanks for everything @Poiz, I owe you that beer ;) – Jay May 12 '16 at 20:26
  • I'd be glad to have that beer... Good you figured it out though **;-)** Perhaps you may just revert back to the original Class and change the name of the table to **stores** since that has always been the main issue... PDO only helped us figure it out faster... **All the Best, Josef** – Poiz May 12 '16 at 20:28