jamesxg1 Posted January 20, 2010 Share Posted January 20, 2010 Hi Everyone! Can anyone see a problem with this query, it is part of a class by the way. $this->getNewIID = "SELECT `replyid`, `id` FROM `answers` ORDER BY `replyid` DESC LIMIT 1"; $this->runGetNewIID = mysql_query($this->getNewIID); while($this->newIID = mysql_fetch_assoc($this->runGetNewIID)): $this->iid = $this->newIID['id'] + 1; endwhile; Many thanks James. Quote Link to comment Share on other sites More sharing options...
gizmola Posted January 20, 2010 Share Posted January 20, 2010 James, No offense intended here, but I don't see the value of what you are doing with classes. It's great you are trying to use them, but it seems you are simply substituting member variables in a class where you could otherwise use temporary variables. There's no value in your example, to using a class variable to store a result set. With that said I don't see an obvious problem with your query syntax. Nevertheless you should check the value of the result returned from mysql_query(). We don't know what your table definition is, but any issue there in naming of columns could cause an error. At very least you should: if ($this->runGetNewIID) { //Got a result, go ahead and fetch in a loop. } else { // check mysql_error() } Quote Link to comment Share on other sites More sharing options...
jamesxg1 Posted January 20, 2010 Author Share Posted January 20, 2010 Hi! None taken the way I see it is if your doing it wrong you must be told lol!. And being told by someone who knows what there doing is all the better. Thank you for the advice due to this I have fixed the problem . Many thanks James. Quote Link to comment Share on other sites More sharing options...
gizmola Posted January 20, 2010 Share Posted January 20, 2010 Hi! None taken the way I see it is if your doing it wrong you must be told lol!. And being told by someone who knows what there doing is all the better. Thank you for the advice due to this I have fixed the problem . Many thanks James. Glad to have helped, and great attitude. +1 for you -- being open to constructive criticism is important for any programmer. Even though I'm an old salt I always learn things from working with other programmers on projects. FWIW, there's what I consider to be some excellent examples of Design pattern driven OOP design in the Zend framework. Take a look at some other their classes and try and understand what they're doing. Learning from the example of others is usually very effective. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.