-3

I'm creating a shopping cart systems and I'm getting this error when trying to add the item to the cart.

<?php 
session_start();

require('inc/connect.php');

if(isset($_GET['action']) && $_GET['action']=="add") {

    $id=intval($_GET['id']);
    if(isset($_SESSION['cart'][$id])) {
        $_SESSION['cart'][$id]['quantity']++;
    }
    else {

        $sql_s ="SELECT * FROM product WHERE product_id = ['id']";
        $query_s=mysql_query($sql_s);
        if(mysql_num_rows($query_s) !=0) {
            $row_s=mysql_fetch_array($query_s);

            $_SESSION['cart'][$row_s['product_id']]==array(
                "quantity" => 1,
                "price" => $row_s['price']);
        }
        else {
            $message="This product id is invalid!";
        }
    }
}

?>

My error is saying line 16 which is:

$query_s=mysql_query($sql_s);
Bob21
  • 153
  • 10

1 Answers1

1

Change ['id'] to $id:

$sql_s ="SELECT * FROM product WHERE product_id = $id";
Lucas Henrique
  • 1,407
  • 1
  • 11
  • 15