Hello, i am creating a e-commerce web site for my final year in BSc Computing and i have a problem with my PHP code.
<?php
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
// Check to see the URL variable is set and that it exists in the database
if (isset($_GET['$product_name'])) {
$product_name = preg_replace('#[A-Z,a-z,0-9]#i', '', $_GET['$product_name']);
/* Use this var to check to see if this ID exists, if yes then get the product
details, if no then exit this script and give message why */
$sql = mysql_query("SELECT * FROM products WHERE id='$product_name' LIMIT 1");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
// get all the product details
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$price = $row["price"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
}
else{
echo "That item does not exist.";
exit();}
}
else{
echo "Data to render this page is missing!.";
exit();
}
mysql_close();
?>
I dont know where is the error i hace added 6 products into my database with ids(1,2,3,4,5,6) and when i try open this page i says Data to render this page is missing!.
Any ideas?
Thank you indeed!