PDA

View Full Version : MySQL Fun!


ast3r3x
2004-07-20, 21:11
I'm creating my own forum board and having some problems. This was working, but I somehow broke it last night and have not a clue how. But here is the deal...

When I try to have my update function update, the topic count, or post count, or reply count or anything, I am getting the same problem as follows.

It outputs what I think should work...hell what was working.


<edit>Not sure where my pictures are, I'll mak sure they get up when I get home.</edit>
Describe:
http://mobocracy.no-ip.com/pictures/describe.jpg
Select:
http://mobocracy.no-ip.com/pictures/select.jpg
Update:
http://mobocracy.no-ip.com/pictures/update.jpg

As you can see, it matches, doesn't change, and gives a warning. One how can I see this warning. Two, why isn't it working. Three why does if I manually set the topiccount to 1, puting that same command I just had, reset it to 0?

PhenixReborn
2004-07-20, 23:34
I can't be totally sure about this since it's been a while since I've used SQL for anything but here goes:

I can see two possible things that might be wrong. First, your use of quotes. You wrote:
Update forums Set topiccount="topiccount+1". The "" indicate a string, but you have it set as an int. I would try removing the quotes, because I know SQL recognizes arithmetice operators. If that doesn't work then there is this:

This is from The Complete MySQL Reference by McGraw-Hill:

MySQL won't let you delete or update a table's data if you are simultaneously reading that same data with a subquery, as doing so raises the possibility that your subquery might reference rows that have already been deleted or altered. There for the table named in an outer DELETE or UPDATE DMl statement cannot appear in the FROM clause of an inner subquery.

ast3r3x
2004-07-21, 17:08
I guess it was the quotes, but I could have swore I checked last night and it didn't make a difference. So maybe I just typed it wrong or something funky was going on. Thanks though, I guess I need to modify my function so I can choose to have quotes or not.

But...this means my website is functioning!