3

I found a post two hours ago, which contained sub-par answers. As usual, I downvoted, posted a comment explaining what they could improve and posted an alternative answer. One of the answerers got back to me and improved the post. However, I still think my answer is good enough to stay.

I have received two downvotes already. Is there anything I could have done differently or could I improve my answer in any way?

My answer

This has been happening to me recently. I post a good clear answer in my opinion with proper explanation, and I either don't get any upvotes or I get downvotes instead. Meanwhile, total trash code-only answers, with serious problems get upvoted and accepted. This is really bringing a man down. I don't demand explanation for downvotes, but I would appreciate constructive feedback. I am not here for the points, but to share knowledge and improve the quality of code examples available online.

I am not asking to explain why these two users voted like they did. They are just two users. I would like to know how to improve my answers in general to get a better reception. Are they unclear? Too complicated? Is there anything I could improve in my answers to get them above the poorly written ones?

18
  • 8
    As far as I see it your first sentence in that answer is wrong. You claim OPs code doesn't work because they don't use prepared statements, but that's wrong. The issue is something else and they just should use prepared statements.
    – Tom
    Dec 26, 2019 at 15:53
  • @Tom Their code does not work. They could work around using quotes, but the real answer is to separate the SQL from the data. This way no workarounds are needed.
    – Dharman Mod
    Dec 26, 2019 at 15:54
  • @Dharman OK... but don't say that your problem at first place is that you get downvoted without understading why, correct me if i'm wrong i insist!. I maybe go to far by proposing a general "solution".
    – Victor
    Dec 26, 2019 at 15:54
  • 2
    Using quotes is no workaround, it is the solution to the direct issue at hand. That this code is then open to SQL injection is another issue and should be addressed in a good, complete answer. But still, your first sentence is incorrect there, or at least very misleading.
    – Tom
    Dec 26, 2019 at 15:57
  • 5
    That question is at best a dupe. Typo would fit as well. I can understand a user with 70 rep points and two months on the site answering it.
    – yivi
    Dec 26, 2019 at 15:59
  • @Tom I don't agree with this statement. Why would anyone bother with variable interpolation and weird quoting issues if there are prepared statements available. I do not mention in my answer that the problem is SQL injection. All I am saying is that the data should be sent separately, so that there are no quoting issues like the one in question.
    – Dharman Mod
    Dec 26, 2019 at 15:59
  • "All I am saying is that the data should be sent separately" No, you say OPs approach is wrong because they don't use prepared statements and that is incorrect. I don't say that your answer in general is incorrect, because it isn't, but the first sentence is factually wrong.
    – Tom
    Dec 26, 2019 at 16:02
  • @yivi Maybe you are right. We do have a canonical for this. However, I try to answer a question if there are other answers already present to counter the bad information. Should I not be doing this? After all, down votes are not meant to discourage people from posting good answers even when there might be a duplicate available.
    – Dharman Mod
    Dec 26, 2019 at 16:03
  • 7
    If you know a question is a dupe, vote to close, do not post an answer.
    – yivi
    Dec 26, 2019 at 16:03
  • 3
    I would start with "Your query doesn't work, because you forgot to quote the variables, so the query ends up with unquoted Strings which is an invalid SQL syntax, but this general query style has a bigger issue: ... [stuff about sql injection and prepared statements]". If then OP decides to ignore the bigger issue and just adds the missing quotes, it is on them, you gave all the required information to explain their current issue and their general issue on using parameterized queries.
    – Tom
    Dec 26, 2019 at 16:07
  • 1
    @Tom Thanks, I have implemented your suggestion.
    – Dharman Mod
    Dec 26, 2019 at 16:11
  • 1
    IMHO, you shouldn't have included yourself in that question, it's what I call a "code trap", where you'd be darned if you did and darned if you didn't. We see questions like that so often, it's enough to make one's head spin. P.s.: I didn't downvote your answer. There was too many things that could go wrong with their code and using bad practices. Dec 26, 2019 at 17:39
  • 2
    @Victor - If a reason was required to vote on a contribution, most people who type gibberish, I know I would in order to avoid having a discussion about my vote. If a comment is required to downvote, then a comment, should be required to upvote. An upvote is just as powerful as a downvote. Votes in either direction indicate if the contribution was helpful or unhelpful. Having been a victim of serial downvoting in entirely unrelated Stack Exchange communities, I know retaliation in the form of massive downvoting (over days, weeks, months) exist Dec 26, 2019 at 17:42
  • 2
    I think some of your recent answers have no votes because it's the end of the year and people are busy/away. A couple are on very old questions, so they may not be getting any attention.
    – BSMP
    Dec 26, 2019 at 19:26
  • 2
    @Cerad renaming 'downvotes' would be as useful as renaming compiler error messages. 'Compilation did not quite proceed as you would, presumably, wish. Sadly, 37 departures from the standard syntax were encountered, resulting in a shortfall of useful object code output. Please help by trying to edit the source files to remove, or bypass, the language specification deviations'. It's computer programming that we deal with, not diplomacy:( Dec 28, 2019 at 13:37

0

Browse other questions tagged .