close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Undefined Variable when in fucntion?

Thread began 10/15/2015 8:29 am by Steve | Last modified 10/19/2015 9:41 am by Steve | 968 views | 2 replies

Steve

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)

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...