Question

I'm trying to update a column count using this code:

UPDATE Tabelltest
SET COUNT = COUNT + 1
WHERE name = 'bla'

However, my count variable is still has the value 0.

When I do count = 2, it will be successfully updated but I want it to increment by one instead.

Was it helpful?

Solution

The following has been made as an answer, where the OP states "cant upvote u but u got it right thx "

It seems obvious then, that you either don't have a column called name and/or there is no value in that column with the word bla in it.

I have a similar piece of code as yours and it works perfectly well.

If one of those conditions isn't met, your query fails.

Plus, make sure your table is called Tabelltest and not Tableltest or Tabletest

That could be a typo which will make all the difference.

Add error reporting to the top of your file(s)

-mysqli-

error_reporting(E_ALL);
ini_set('display_errors', 1);

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

PDO

MySQL (error reporting links)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top