@#$%^ quotes
damnit! I can't easily let go of a problem, especially code and now I'm up way too late. So here I am trying to implement a new comment system for my site(s) so they a: don't get spammed, and b: are more efficient and use the same code everywhere for every comment section. I know exactly what I have to do and what I have to write and basically need to start over with a new set of tables in the db. This will require transplanting any and all old records across multiple tables into the new all in one table, so I need to write some new code to do the moving/tidying up.
And what do you know? Nothing works. It works, but it clearly is not giving me the right results as a single comment begins appearing multiple times and belonging to multiple pages. So I'm researching like mad for a few hours here trying everything from disabling concurrent writes to changing storage engines and absolutely nothing is working. I'm hopping between 3 exact different ways of getting the wrong response and never getting closer.
Then I notice that for some reason, even with the dupes, if I weed them out there are missing results. It's like they just skipped an insert. So I read some more and find out that this one function will fail and revert to a previous value if the previous insert failed and will continue to do so until a new value is received, even if you never receive an error (ie, error reporting off, etc)
So I drop back to the old 'or die(“failed -> $query”)' after the insert to find out which record or what text might be killing it. Turns out it's dying on the very first insert, and quite a few after that leading to the multiple repeats and the very first record being 0 instead of 1. Check out the first insert.
Loaded… with… quotes and apostrophes.
ffs…
A single addslashes() later and it all works. And here I thought I had the whole quote thing taken care of long ago with magicquotes enabled and whatnot in figuring out how to properly move text around given the issues I've faced my whole damn life of trying to explain to people what an apostrophe is and why your computer system sucks for not recognizing it. And then I go and make the same damn mistake… again! I'm willing to bet I get hung up on a missing comma or semi-colon next.
Filed in Hackery No Responses yet



