doushang2021 2015-12-13 08:10
浏览 171

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

I was just wondering if I could get some help with this big website project I have for my introductory web programming class. The website is supposed to be a little online store with a home page, a shop page, and a checkout page.

I cannot seem to get the checkout page to work, as when I grade the assignment it gives me 7 "object not found" errors.

My professor told me that I have 1 extra character in my SQL that causes a critical error but I cannot find it for the life of me.

Here's my code:

<?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>";

?>

Any help would be greatly appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
    • ¥15 onvif+openssl,vs2022编译openssl64
    • ¥15 iOS 自定义输入法-第三方输入法
    • ¥15 很想要一个很好的答案或提示