0

Im getting an sql error saying "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"

These are the 2 queries...

$sql = "DELETE FROM tbl_category WHERE cat_id=$cid";

$sql2="INSERT INTO tbl_sales (order_id,customer_id) VALUES ($row[order_id],$row[cus_id]) WHERE order_id='$index'";

Cannot figure it out whats wrong? can some one help me please..

4
Contributors
9
Replies
10
Views
7 Years
Discussion Span
Last Post by sami.asanga
0

yeah..tried it in that way too...:(

but same error is continuously appearing...is it something because of the variables which I have used??

0

Your missing single quotes around $cid

cat_id = '$cid' ";

I think. Can you post the whole script or attach it as a file?

0

yaa...this is it...:)

1.

if(isset($_POST["btnDelete"])){
 
	$cid         = $_POST['catId'];
	$name3       = $_POST['txtName'];
	//$image3		 = $_POST['file'];
	
	//Remove the product from the database
	$sql    = "DELETE FROM tbl_category WHERE cat_id = '$cid'";
		   
	$result2 = mysql_query($sql) or die(mysql_error());
	unlink($image2);
	header('Location: ../categories.php');
	
}

2.

foreach($_POST['status'] as $index){
			if(isset($_POST["btnAccept"])){
				$sql2="INSERT INTO tbl_sales (order_id,customer_id) VALUES ($row[order_id],$row[cus_id]) WHERE order_id = '$index'";
			$result2=mysql_query($sql2) or die(mysql_error());
                      }
          }
0

Best thing I can think of at the moment is to give your the script I used to create my deletions:

<?php
    $mysqli = new mysqli("localhost", "catalog_user", "secret", "catalog_prod");
    // Create the query
    $query = "DELETE FROM products WHERE sku = 'TY232278'";
        // Send the query to MySQL
        $result = $mysqli->query($query, MYSQLI_STORE_RESULT);
        // Tell the user how many rows have been affected
        printf("%d rows have been deleted.", $mysqli->affected_rows);
    ?>
0

@rch1231,

You are code seems to be unclear for me..:(

@pritaeas,

ohh is that so..But I need to insert the order which are accepted by the admin to the sales table..Then how should I do it?? Can you please help me..

0

Maybe you replace INSERT by something like this:

update products set quantity = quantity - quvalue_from_admin_list 
  where id_quantity = idvalue_from_admin_list

This would somewhat coincide with your other posting.

I have assumed that your admin's list is a sales list, therefore quantities on stock must be reduced by sold amounts.

-- tesu

Edited by tesuji: n/a

0

yaa may be related because the same system am talking about..:)
but what i said here is both insert and delete queries which I used is giving me an error...

And cannot use update here right?? because I need to insert the entries to a separate table ...

Btw Thanks all for you are replies..But the problem is still same..:(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.