首先,我是新的PHP sysql和數據庫。我知道一點C++,所以這有助於PHP。我真的不明白數據庫雖然所以我的問題是:.....試圖把本地PHP的購物車到godaddy和有問題
這是我的代碼:
<?php
echo $_SERVER['DOCUMENT_ROOT'].'/'.'lensClensProducts/views/layouts/'.$controller.'.php';
// Includes our database functions
include('db_functions.php');
// includes our cart functions
include('cart_fns.php');
session_start();
// set up default cart values
if(!isset($_SESSION['cart']))
{
$_SESSION['cart'] = array();
$_SESSION['total_items'] = 0;
$_SESSION['total_price'] = '0.00';
}
// Defaults to index view unless user requests different view
$view = empty($_GET['view']) ? 'index' : $_GET['view'];
// Used for layout
$controller = 'shop';
// checks which view is requested by user.
switch ($view) {
case "index":
$products = find_products();
break;
case "add_to_cart":
$id = $_GET['id'];
$add_item = add_to_cart($id);
$_SESSION['total_items'] = total_items($_SESSION['cart']);
$_SESSION['total_price'] = total_price($_SESSION['cart']);
header('Location: index.php');
break;
case "update_cart":
update_cart();
$_SESSION['total_items'] = total_items($_SESSION['cart']);
$_SESSION['total_price'] = total_price($_SESSION['cart']);
header('Location: index.php?view=checkout');
break;
case "checkout":
if (0 < $_SESSION['total_price'] && $_SESSION['total_price'] <= 100 )
{
$shipping = 11.95;
}
if (100 < $_SESSION['total_price'] && $_SESSION['total_price'] <= 250 )
{
$shipping = 18.50;
}
if (250 < $_SESSION['total_price'] && $_SESSION['total_price'] <= 500 )
{
$shipping = 25.50;
}
if (500 < $_SESSION['total_price'] && $_SESSION['total_price'] <= 1000)
{
$shipping = 36.00;
}
if (1000 < $_SESSION['total_price'] && $_SESSION['total_price'] <= 2500)
{
$shipping = 64.50;
}
else if (2500 < $_SESSION['total_price'])
{
$shipping = 250.00;
}
break;
}
// includes layout for controller
include($_SERVER['DOCUMENT_ROOT'].'/'.'lensClensProducts/views/layouts/'.$controller.'.php');
?>
我有最後一行包括一個問題($ _ SERVER ['DOCUMENT_ROOT ']。'/'。'gamelist/views/layouts /'.$ controller。'。php');
PS上也有此代碼
一個特別是[「DOCUMENT_ROOT」]我想這是一個全局變量的線16的回聲。
IM的本地主機這個節目並能正常工作,在轉到爸爸,這並不做任何事情,但給我一個錯誤
警告:在session_start()[function.session啓動]:不能發送會話cookie - (已在/home/content/27/6235127/html/gamelist/index.php:4開始輸出)在線16上的/home/content/27/6235127/html/gamelist/index.php中已發送的頭文件
警告:session_start()[function.session-start]:無法發送會話緩存限制器 - 已在/ home/content/27/6235127/html/gamelist/index.php on line 16 /gamelist/views/layouts/index.php
我不確定這與服務器名稱有關我使用的服務器名稱lensclens3.db.6235127.hostedresource.com,並沒有工作。
我知道上面這個服務器名稱的作用,因爲它在這個購物車的另一頁上使用(和工作)。
我應該使用另一個服務器名稱嗎?
[Headers already already sent by PHP]可能重複(http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – deceze