I have been getting this error. I have no idea what it is. Any help provided would be awesome.
`require "connect.php";
$query = "SELECT DVD ID, Name Of the DVD, Quantity FROM DVD";
$stmt = $dbhandle->prepare( $query );
$stmt->execute();`
This is where I am getting my error. I researched about the error, they are saying the problem could be with $dbhanle not sure though.
The rest of the code is below.
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Shopping Cart</title>
<link type="text/css" rel="stylesheet" href="basket.css" />
</head>
<body>
<?php
$action = isset($_GET['action']) ? $_GET['action'] : "";
$name = isset($_GET['Name Of the DVD']) ? $_GET['Name Of the DVD'] : "";
if($action=='add'){
echo "<div>" . $name . " was added to your cart.</div>";
}
if($action=='exists'){
echo "<div>" . $name . " already exists in your cart.</div>";
}
require "connect.php";
$query = "SELECT DVD ID, Name Of the DVD, Quantity FROM DVD";
$stmt = $dbhandle->prepare( $query );
$stmt->execute();
$num = $stmt->rowCount();
if($num>0){
echo "<table border='0'>";//start table
// our table heading
echo "<tr>";
echo "<th class='textAlignLeft'>DVD Name</th>";
echo "<th>Quantity</th>";
echo "<th>Action</th>";
echo "</tr>";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
//creating new table row per record
echo "<tr>";
echo "<td>{$name}</td>";
echo "<td class='textAlignRight'>{$price}</td>";
echo "<td class='textAlignCenter'>";
echo "<a href='AddToCart.php?id={$id}&name={$name}' class='customButton'>";
echo "<img src='images/add-to-cart.png' title='Add To Cart' />";
echo "</a>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
// no products in the database
else{
echo "No products found.";
}
?>
</body>
</html>
Thank you for your time