in PHP $_GET
is an associative array, so in the case of $_GET['VIN']
the index is 'VIN'
. $_GET
is filled with parameters passed in the url, while it is possible to change how your http server handles get parameters the most common is like this http://yoursite.com/mypage.php?parameter1=value1¶meter2=value2
in your case since since your are receiving the error on line 10 it means there is no item in your $_GET
array with the index of 'VIN'
. The easiest way to prevent this error would be something like this
<?php include 'db.php';
if(isset($_GET['VIN'])){
$vin=$_GET['VIN'];
$query="SELECT * FROM INVENTORY WHERE VIN=:vin";
$stmt=$pdo->prepare($query);
$stmt->bindParam(':vin',$vin);
$products = array();
if ($stmt->execute()){
//handle results
}
}else{
//handle VIN not being set
}
Please also note that you should not concatenate your query, ever so in my example I showed using PDO and a prepared statement. you can learn more about using PDO here http://php.net/manual/en/book.pdo.php