0

I have been staring at this query for ages trying to figure out why I am getting the error as stated in the title and for the life of me cannot see hot to correct it. All fields are correct and all POST values are being posted correctly. I would be grateful if someone with fresh eyes could point out the error. Many thanks.

$id = $_POST['id'];
$rack = strtoupper($_POST['slot']);
$column = $_POST['column']; <---INT
$row = $_POST['row']; <---INT
$bay = $_POST['bay']; <---INT
$size = $_POST['size'];
$service = ucfirst($_POST['service']);
$activity = ucwords($_POST['activity']);
$dept = $_POST['dept'];
$company = $_POST['company'];
$address = ucwords($_POST['address']);
$user = ucwords($_POST['user']);
$box = $_POST['item

'];

$query = "UPDATE `boxes` SET `rack` = '".$rack."',`column` = $column,`row` = $row,`bay` = $bay,`status` = '1',`customer` = '".$company."', `department` = '".$dept."',`request` = 0,`custref` = '".$box."',`size` = '".$size."',`authorisation` = '".$user."' WHERE `department` = '".$dept."',`customer` = '".$company."',`custref` = '".$box."'";
      mysqli_query($conn, $query) or die('Error, box action failed'. mysqli_error($conn));
9
  • 2
    Can you please add the syntax error to the question? Commented Jun 15, 2018 at 9:47
  • 4
    Also, bobby tables would like to have a word with you Commented Jun 15, 2018 at 9:47
  • check the where clause, you have error in your where clause. Commented Jun 15, 2018 at 9:48
  • 2
    Stare a little more at your where clause Commented Jun 15, 2018 at 9:48
  • @kerbholz I'm staring but still cannot see it? could you point it out. thanks Commented Jun 15, 2018 at 9:51

2 Answers 2

2

You should use AND instead of , in WHERE

Change

WHERE `department` = '".$dept."',`customer` = '".$company."',`custref` = '".$box."'";

to

WHERE `department` = '".$dept."' AND `customer` = '".$company."' AND `custref` = '".$box."'";
Sign up to request clarification or add additional context in comments.

Comments

0

In your where it's not , it's and between the clauses:

$query = "UPDATE `boxes` SET `rack` = '".$rack."',`column` = $column,`row` = $row,`bay` = $bay,`status` = '1',`customer` = '".$company."', `department` = '".$dept."',`request` = 0,`custref` = '".$box."',`size` = '".$size."',`authorisation` = '".$user."' WHERE `department` = '".$dept."' AND `customer` = '".$company."' AND `custref` = '".$box."'";
  mysqli_query($conn, $query) or die('Error, box action failed'. mysqli_error($conn));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.