0

I have PHP code like this:

$query = 'UPDATE  `user_vote` SET `container` = CONCAT(`container`, ' ;
$query .=  ",$glas";
$query .= ') WHERE `user_id` = ' . $id_u;
$this->db->query($query);

When I run this code, I got following error:

Error Number: 1054

Unknown column ',iljadu' in 'field list'

UPDATE user_vote SET container = CONCAT(container, ,iljadu) WHERE user_id = 4

What is wrong with the query?

2 Answers 2

4

You are missing quotes around your variable for the concat()

$query = 'UPDATE  `user_vote` SET `container` = CONCAT(`container`, ' ;
$query .=  ",'$glas'";
$query .= ') WHERE `user_id` = ' . $id_u;
$this->db->query($query);
Sign up to request clarification or add additional context in comments.

4 Comments

$glas could contain a column identifier, but I suspect you are correct. Still too many commas though... ;-)
@DaveRandom Concat() can contain a column name or a string. In this case my big nose is telling me that it is a string that is being appended with a column - in which case there are quotes missing around it. I got a good feeling about this one :)
This is working, thank you :). @DaveRandom I need coma, but I put it at wrong place. ",'$glas'"; should be "',$glas'"; and everything works fine.
@Sasha Super, feel free to Accept the answer and we can all call it a night :)
1
$query .=  ",$glas";

should be

$query .=  "$glas";

1 Comment

Concat() has parameters that are separated by commas?

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.