[SOLVED] it works on localhost but not on hosting account?
Hello all
im new to php and smarty
I have developed a wedsite using these and on my localhost the script works fine no errors in my logs and when testeing all the functions, it works great.
I ftp all my files to my host and now all i get is a blank page. This is realy frustrating as i cannot find any errors in the code. there is also no errors in the logs of my hosting account which is even more frustrating.
i was realy hoping i could get some help, im not sure what information you will need but here's a short breakdown
My comp:
O.S windows vista business
Apache
PHP5
mysql
code written in php using smarty templates. The website worked previously on the hosting account when i put it on to test i took it off changed nothing put it back on and the problem started.
Please help someone ! this has been the 3rd week of trying to debug and my foot is comming closer to the comp.
I have also put smarty into my public html. Was this right?
Im realy desperate!
Thanks all look forward to the reply (ok anticapate)
I'm no expert and I apologise if this undermines you.
Are the locations in your script set to local locations instead of global and if they are relative, are they now relative to some other location now that they are on the server?
Are you using code that is unsupported by your server's php version but is supported locally?
That should display the errors you are getting. If that doesnt show, then it is more than likely problems with the file structure differences. Also, check that both systems have the same PHP version (5)
<?php
// load Smarty library and config files
require_once 'include/app_top.php';
/* if not visiting a product page, save the link to the current page
in the PageLink session variable; it will be used to create the
Continue Shopping link in the product details page and the links
to product details pages */
if (!isset($_GET['ProductID']) && !isset($_GET['CartAction']))
$_SESSION['PageLink'] = "http://" . $_SERVER['SERVER_NAME'] .
":" . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
//load business tier
require_once SITE_ROOT . '/business_objects/bo_catalog.php';
require_once SITE_ROOT . '/business_objects/bo_shopping_cart.php';
require_once SITE_ROOT . '/business_objects/bo_customer.php';
// Load Smarty template file
$page = new Page();
$pageContentsCell = "first_page_contents.tpl";
$categoriesCell = "blank.tpl";
// Load department details if visiting a department
if (isset($_GET['DepartmentID']))
{
$pageContentsCell = "department.tpl";
$categoriesCell = "categories_list.tpl";
}
if (isset($_GET['Search']))
$pageContentsCell="search_results.tpl";
if (isset($_GET['ProductID']))
$pageContentsCell = "product.tpl";
if (isset($_GET['CartAction']))
{
$pageContentsCell = "shopping_cart.tpl";
$cartSummaryCell = "blank.tpl";
}
else
$cartSummaryCell = "cart_summary.tpl";
// customer accounts functionality
$bo_customer = new BoCustomer();
if ($bo_customer->IsAuthenticated())
$customerLoginOrLogged="customer_logged.tpl";
else
$customerLoginOrLogged="customer_login.tpl";
if (isset($_GET['RegisterCustomer']) || isset($_GET['ChangeDetails']))
$pageContentsCell="customer_details.tpl";
if (isset($_GET['AddOrChangeAddress']))
$pageContentsCell="customer_address.tpl";
if (isset($_GET['AddOrChangeCreditCard']))
$pageContentsCell="customer_credit_card.tpl";
$page->assign("cartSummaryCell", $cartSummaryCell);
$page->assign("pageContentsCell", $pageContentsCell);
$page->assign("categoriesCell", $categoriesCell);
$page->display('index.tpl');
//Load app_bottom which closes the database connection
require_once 'include/app_bottom.php';
?>
this is my database file
PHP Code:
<?php
// reference the PEAR DB library
require_once 'DB.php'; //i have referenced the correct path for hosting account
//class providing generic data access functionality
class DbManager
{
public $db;
//open database connectionin the constructor
function __construct($connectionString)
{
$this->db = DB::connect($connectionString,
'USE_PERSISTENT_CONNECTIONS');
if (DB::isError($this->db))
trigger_error($this->db->getMessage(), E_USER_ERROR);
$this->db->setFetchMode(DB_FETCHMODE_ASSOC);
}
// close connection
public function DbDisconnect()
{
$this->db->disconnect();
}
public function DbQuery($queryString)
{
$result = $this->db->query($queryString);
}
// wrapper class for PEAR DB's getAll() method
public function DbGetAll($queryString)
{
$result = $this->db->getAll($queryString);
if (DB::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for PEAR DB's getRow() method
public function DbGetRow($queryString)
{
$result = $this->db->getRow($queryString);
if (DB::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for PEAR DB's getOne() method
public function DbGetOne($queryString)
{
$result = $this->db->getOne($queryString);
if (DB::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for the escapeSimple() method
public function DbEscapeSimple($string)
{
if (get_magic_quotes_gpc())
return $string;
else
return $this->db->escapeSimple($string);
}
}
?>
and my config file
PHP Code:
<?php
// SITE_ROOT contains the full path to the tshirtshop folder
define("SITE_ROOT", dirname(dirname(__FILE__)));
// Settings needed to configure the Smarty template engine
define("SMARTY_DIR", SITE_ROOT."/libs/smarty/");
define("TEMPLATE_DIR", SITE_ROOT."/templates");
define("COMPILE_DIR", SITE_ROOT."/templates_c");
define("CONFIG_DIR", SITE_ROOT."/configs");
// these should be true while developing the web site
define("IS_WARNING_FATAL", true);
define("DEBUGGING", true);
// settings about mailing the error messages to admin
define("SEND_ERROR_MAIL", false);
define("ADMIN_ERROR_MAIL", "some@email");
define("SENDMAIL_FROM", "some@email");
ini_set("sendmail_from", SENDMAIL_FROM);
// by default we don't log errors to a file
define("LOG_ERRORS", false);
//define("LOG_ERRORS_FILE", "c:\\tshirtshop\\errors_log.txt"); // Windows
// define("LOG_ERRORS_FILE", "/var/tmp/tshirtshop_errors.log"); // Unix
// Generic error message to be diplayed instead of debug info
// (when DEBUGGING is false)
define("SITE_GENERIC_ERROR_MESSAGE", "<h2>TShirtShop Error!</h2>");
//include path to enable PEAR DB
if ((substr(strtoupper('PHP'-'OS'), 0, 3)) == "WIN")
define("PATH_SEPARATOR", ";");
ini_set('include_path', SITE_ROOT . '/libs/pear/' . // again corrected for host
PATH_SEPARATOR . ini_get('include_path'));
//datbase login info
define("USE_PERSISTANT_CONNECTIONS", "true");
define("DB_SERVER", "something");
define("DB_USERNAME", "something");
define("DB_PASSWORD", "password");
define("DB_DATABASE", "something");
define("MYSQL_CONNECTION_STRING", "mysql://" . DB_USERNAME . ":" .
DB_PASSWORD . "@" . DB_SERVER . "/" . DB_DATABASE);
// Configure product display options
define("SHORT_PRODUCT_DESCRIPTION_LENGTH",130);
define("PRODUCTS_PER_PAGE",4);
// minimum word length for searches; this constant must be kept in sync
// with the ft_min_word_len MySQL variable
define("FT_MIN_WORD_LEN",4);
// shopping cart item types
define("GET_CART_PRODUCTS",1);
define("GET_CART_SAVED_PRODUCTS",2);
// cart actions
define("ADD_PRODUCT",1);
define("REMOVE_PRODUCT",2);
define("UPDATE_PRODUCTS_QUANTITIES",3);
define("SAVE_PRODUCT_FOR_LATER",4);
define("MOVE_PRODUCT_TO_CART",5);
// admin login info
define("ADMIN_USERNAME", "something");
define("ADMIN_PASSWORD", "something");
// random value used for hassing
define("HASH_PREFIX", "K1-");
// constant definitions for commerce lib classes
define("COMMERCELIB_DIR", SITE_ROOT . "/business_objects/commerce_lib/");
define("NEWLINE", "\n");
// constant definitions for order handling related messages
define("ADMIN_EMAIL","some@email");
$admin_email_params=array('host' => 'some@email',
'auth' => true,
'username' => 'some@email',
'password' => 'password');
define("CUSTOMER_SERVICE_EMAIL","some@email");
$customer_service_email_params = array('host' => 'some@email',
'auth' => true,
'username' => 'some@email',
'password' => 'password');
define("ORDER_PROCESSOR_EMAIL","bpike@blankcanvas-art.co.uk");
$order_processor_email_params = array('host' => 'some@email',
'auth' => true,
'username' => 'some@email',
'password' => 'password');
define("SUPPLIER_EMAIL","some@email");
define("DATACASH_DIR", SITE_ROOT . "/business_objects/datacash_lib/");
?>
Thanks all further info if you require also my hosting account uses linux system which is prob a big problem i think.
Thanks for the quick replies i didnt mention that i had an error reporting file that catches all of the errors and displays them (usualy) hope the code is of use to someone
my hosting account uses linux system which is prob a big problem i think.
If both are using apache and the same version of php, it shouldnt make a difference whatsoever really. Another thing to check is the file permissions. The file structure is the path to each file, ie on your localhost it will be something like C:\server\public\ whereas on your linux machine it will be something like /home/username/public_html/ so you need to make sure that you have all of them set relative to each other correctly
mmm i did think this aswell and went through all my code and changed paths to the absolute locations and i realy thought this was going to be the problem thing is it made no difference what so ever.
the thing im finding most frustrating is the lack of errors im getting is it possible that if there is a syntax error and i have an error handler and hosting account has log files i get nothing its incredible.
Looks like you're jumping straight in at the deep end then, by using classes.
Absolute paths in your script e.g. pointing to http://domain.com/script.php will work regardless of where the script is being hosted (locally or on the server) as it points directly to the file.
If you used a link to /script.php on your server it would equate to http://domain.com/script.php whereas on your desktop or root of your hard drive locally (depending what folder(s) the script was stored in locally).
If you didn't know about relative and absolute linking, you may be trying to do too much too early on in your php learning curve..
sorry i know im going on a bit, i also defined the path seperators and defined other things incase the hosting provider uses a unix flavor and again nothing