Undefined Variable when in fucntion?
Hello,
Trying to update an old page with new MySQLi code but not able to get past and Undefined Variable being thrown on a simple check for TotalRows == 0
<?php
$Recordset1 = new WA_MySQLi_RS("Recordset1",$rtk_i,1);
$Recordset1->setQuery("SELECT * FROM cart WHERE cart.cookieId = ? AND cart.itemId = ?");
$Recordset1->bindParam("s", "".$cookieID ."", "t8mj61d4mbhlq6o1osedmus5f2"); //coookie
$Recordset1->bindParam("i", "".$itemID ."", "2801"); //itemidd
$Recordset1->execute();
?>
<?php
// check ItemID and Cookie to see if present?>
<?php //echo $Recordset1->debugSQL();
?>
<?php
// delete connection:
include("../Connections/db.php");
switch($_GET["action"])
{
case "add_item":
{
AddItem($_GET["id"]);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET["id"]);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET["id"]);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
function AddItem($itemID)
{
// Will check whether or not this item
// already exists in the cart table.
// If it does, the UpdateItem function
// will be called instead
// Check if this item already exists in the users cart table
if ($Recordset1->TotalRows == 0 ) {
// This item doesn't exist in the users cart,
// we will add it with an insert query
if ("" == "") {
$InsertQuery = new WA_MySQLi_Query($rtk_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "cart";
$InsertQuery->bindColumn("cookieId", "s", "$cookieID", "WA_DEFAULT");
$InsertQuery->bindColumn("itemId", "i", "$itemID", "WA_DEFAULT");
$InsertQuery->saveInSession("id_sess");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
//@mysql_query("insert into cart(cookieId, itemId) values('" . GetCartId() . "', $itemID)");
}
else
{
// This item already exists in the users cart,
// we will update it instead
UpdateItem($itemID);
}
}
Error:
Notice: Undefined variable: Recordset1 in ..... (more detailed errors in attached screen shot)