PHP结帐页面无法使用“找不到对象”错误

时间:2015-12-13 08:10:14

标签: javascript php html web-site-project

我只是想知道我是否可以获得一些关于这个大型网站项目的帮助,我的介绍性网络编程课程。该网站应该是一个小型的在线商店,主页,商店页面和结帐页面。

我似乎无法让结帐页面正常工作,因为当我对作业进行评分时,它会给我7"找不到对象"错误。

我的教授告诉我,我的SQL中有一个额外的字符会导致严重错误,但我无法在我的生活中找到它。

这是我的代码:

<?php

    session_start();

    //include php library

    include("website 01 library.php");

    echo "<h1 id = 'header' class = ''>CHECKOUT</h1>";

    $category = $_SESSION[category];

    $host_name = "localhost";

    $user_name = "web";

    $password = "programming";

    $database = "assignments";

    $connection = mysqli_connect($host_name, $user_name, $password, $database);

    $sql = "select * from cart, product, where cart.productid = product.productid";

    $recordSet = mysqli_query($connection, $sql);

    $total = 0;

    // Process the recordset in a loop

    while ($record = mysqli_fetch_array($recordSet, MYSQLI_ASSOC)) {

        $productid = $record[productid];

        $title = $record[title];

        $quantity = $record[quantity];

        $price = $record[price];

        $totalCost = $price * $quantity;

        $total = $total + $totalCost;

        // product name

        echo "<td id = 'title_$productid' class = ''>$title</td>";

        // quantity purchased

        echo "<td id = 'quantity_$productid' class = ''>$quantity</td>";

        //price

        echo "<td id = 'price_$productid' class = ''>$price</td>";

        $totalCost_productid = $totalCost_productid + $price;

        //echo "<td id = 'totalCost_$productid = quantity_$productid * price_$productid></td>";
        // total cost for product (calculate as quantity * price)
        //echo "<td id = 'totalCost_$productid' class = ''></td>";

        mysqli_close($connection);

        mysqli_free_result($recordSet);

    };

    echo "<td id = 'total' class = ''>$total</td>";

    echo $totalCost_productid;

    mysqli_close($connection);

    mysqli_free_result($recordSet);

    echo "<table class = '' border = 1>";

        echo "PRODUCT<tr>";

        echo "<td class = ''></td>";

        echo "<td class = ''></td>";

    echo "</tr>";

    echo "QUANTITY<tr>";

    echo "<td class = ''></td>";

    echo "<td class = ''></td>";

echo "</tr>";

echo "<table class = '' border = 1>";

    echo "PRICE<tr>";

    echo "<td class = ''></td>";

    echo "<td class = ''></td>";

echo "</tr>";

echo "TOTAL COST<tr>";

echo "<td class = ''></td>";

echo "<td class = ''></td>";

echo "</tr>";

echo "</table>";

?>

非常感谢任何帮助。

0 个答案:

没有答案