Jump to content

Recommended Posts

So ive been bugging you guys about the delete function but nvm. Im just going to change the product to have a variable that is either a 1 or a 0. 0 being (not deleted) and 1 being vice versa. but im having a problem getting the insert update to find the productId here is the code

 

	if($products == TRUE){	
	if(isset($_POST['deleted'])) {
		$record["deleted"] = $db->mySQLSafe($_POST['deleted']);
			$where = "productId = ".$results[$i]['productId'];
		$insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where);
	}else{
	   	$artist_console->assign("ERR_DEL",$lang['front']['viewOrder']['err_del']);
	}

This is the error i get

 

MySQL Error Occured

1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

QUERY = UPDATE cc_CubeCart_inventory SET `deleted`='1' WHERE productId =

 

its not finding the product id

so that means this is wrong

$where = "productId = ".$results[$i]['productId'];

and i dont know how to get it to work

where should i echo? im still new to php i can edit it but i cant really make code yet. sorry

 

well here i tried this tell me if its right

 

if(isset($_POST['deleted'])) {

$record["deleted"] = $db->mySQLSafe($_POST['deleted']);

$where = "productId = ".$db->mySQLSafe($_POST['productId'])." AND cat_id = ".$db->mySQLSafe($_POST['cat_id']);

$insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where);

        echo $insert

 

 

 

$insert is probably a resource, so it probably won't show anything useful, but I don't know what your class is returning. Otherwise, looks right, assuming you have a 'productid' in the $_POST array. I don't know how your code works because you havn't shown much. It would be easier for people to help you if you showed more code.

k heres the form code

 

<form name="delete" action="index.php?act=artistConsole" enctype="multipart/form-data" method="post">
	<input name="deleted" type="hidden" class="textbox" value="1">
        <input name="productid" type="hidden" class="textbox" value="{PRODUCT_ID}" />
        <input name="submit" type="submit" value="Delete" class="submit" />
        </form>

 

php code

				if(isset($_POST['deleted'])) {
					$record["deleted"] = $db->mySQLSafe($_POST['deleted']);
					$record["productId"]= $db->mySQLSafe($_POST['productId']);
					$where = "productId = ".$db->mySQLSafe($_POST['productId']);
					$insert = $db->update($glob['dbprefix']."CubeCart_inventory", $record , $where);

				}else{
					$artist_console->assign("ERR_DEL","Error, Cannot Delete For Some Reason"); 
					$artist_console->parse("artist_console.order_true.session_true.error_true");

				}

db class code

 

function update ($tablename, $record, $where)
{
	if(!is_array($record)) die ($this->debug("array", "Update", $tablename));

	$count = 0;

	foreach ($record as $key => $val)
	{
		if ($count==0) $set = "`".$key."`"."=".$val;
		else $set .= ", " . "`".$key."`". "= ".$val;
		$count++;
	}	

	$query = "UPDATE ".$tablename." SET ".$set." WHERE ".$where;

	$this->query = $query;
	mysql_query($query, $this->db);
	if ($this->error()) die ($this->debug());

	if ($this->affected() > 0) return true; else return false;

} // end update

This is the error i get when i echo the $query on the db.inc.php

 

UPDATE cc_CubeCart_sessions SET `location`='/index.php?act=artistConsole', `timeLast`= '1187801649' WHERE sessId='a018db8f867e287d0b826fad1c40d886'UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''UPDATE cc_CubeCart_inventory SET `deleted`='1', `productId`= '' WHERE productId = ''

Are you typing a product id in?

 

It would seem that $db->mySQLSafe() is returning a null value when passing $_POST['productId']. Of course, it might be null before it is passed. Try putting an echo $_POST['productId'] right after the line "if(isset($_POST['deleted'])) {" and see what it outputs. Doing something like echo "!!$_POST['productId']!!"; makes it easier to spot where in the output it is.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.