Fatal error: Call to a member function bind_param() on strin
Posted: Sun Jul 19, 2015 1:03 pm
Fatal error: Call to a member function bind_param() on string in D:\xamp\htdocs\login-check1\cart_update.php on line 17......
Below is phpcode please help me to figure it out....its urgent.....
***** PLEASE USE PHP CODE TAG *****
Below is phpcode please help me to figure it out....its urgent.....
***** PLEASE USE PHP CODE TAG *****
Code: Select all
<?php
session_start();
include_once("config.php");
//add product to session or create new one
if(isset($_POST["type"]) && $_POST["type"]=='add' && $_POST["product_qty"]>0)
{
foreach($_POST as $key => $value){ //add all post vars to new_product array
$new_product[$key] = filter_var($value, FILTER_SANITIZE_STRING);
}
//remove unecessary vars
unset($new_product['type']);
unset($new_product['return_url']);
$product_code = $_POST['product_code'];
//we need to get product name and price from database.
$statement = "SELECT product_name, price FROM products WHERE product_code='$product_code' LIMIT 1";
$statement->bind_param('s', $new_product['product_code']);
$res = mysql_query($statement);
$statement->bind_result($product_name, $price);
while($statement = mysql_fetch_object($res)){
//fetch product name, price from db and add to new_product array
$new_product["product_name"] = $product_name;
$new_product["product_price"] = $price;
if(isset($_SESSION["cart_products"])){ //if session var already exist
if(isset($_SESSION["cart_products"][$new_product['product_code']])) //check item exist in products array
{
unset($_SESSION["cart_products"][$new_product['product_code']]); //unset old array item
}
}
$_SESSION["cart_products"][$new_product['product_code']] = $new_product; //update or create product session with new item
}
}
//update or remove items
if(isset($_POST["product_qty"]) || isset($_POST["remove_code"]))
{
//update item quantity in product session
if(isset($_POST["product_qty"]) && is_array($_POST["product_qty"])){
foreach($_POST["product_qty"] as $key => $value){
if(is_numeric($value)){
$_SESSION["cart_products"][$key]["product_qty"] = $value;
}
}
}
//remove an item from product session
if(isset($_POST["remove_code"]) && is_array($_POST["remove_code"])){
foreach($_POST["remove_code"] as $key){
unset($_SESSION["cart_products"][$key]);
}
}
}
//back to return url
$return_url = (isset($_POST["return_url"]))?urldecode($_POST["return_url"]):''; //return url
header('Location:'.$return_url);
?>