bundyxc Posted August 9, 2009 Share Posted August 9, 2009 Here's my code: DECLARE @today INTEGER DECLARE @all INTEGER UPDATE `users` SET `url` = 'turtle', `img` = 'images/nopic.png', (`todayLogins` = @today = @today + 1), (`allLogins` = @all = @all + 1), WHERE `friendID` = '382009778' I'm a total SQL noob, so here's my error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @today INTEGER DECLARE @all INTEGER UPDATE `users` SET `url` = 'turtle',' All I'm looking for is a code to create a simple counter, and apparently this isn't it. Can somebody point out what I'm doing wrong, or provide example code of something I can do better? Thanks for your time. Link to comment https://forums.phpfreaks.com/topic/169448-solved-simple-mysql-counter/ Share on other sites More sharing options...
Daniel0 Posted August 9, 2009 Share Posted August 9, 2009 The manual is a great place! DECLARE is allowed only inside a BEGIN ... END compound statement and must be at its start' date=' before any other statements.[/quote'] Anyway, I don't get what you're trying to do. Can't you just do like this? UPDATE users SET allLogins = allLogins + 1 WHERE friendID = 123; Link to comment https://forums.phpfreaks.com/topic/169448-solved-simple-mysql-counter/#findComment-894018 Share on other sites More sharing options...
bundyxc Posted August 9, 2009 Author Share Posted August 9, 2009 After I posted, I decided to rtfm. I was actually just on my way back here to declare the topic as solved. Thank you for providing your code though. Link to comment https://forums.phpfreaks.com/topic/169448-solved-simple-mysql-counter/#findComment-894042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.