| |||||||||||
| |||||||||||
Failing to write all data to file Posted by dabbler (dabbler), 30 May 2003 Hi Graham. ![]() After 3 hours of picking through code and the php manual, I am stuck. Please forgive me if this post is not in following with the intended nature of this forum. It's my last resort. I'd greatly appreciate a little help with this. I have a set of scripts that run a banner management system. It's great but for one problem that is making unusable. It looks to me like it could be something simple that I just don't know enough to see. Or it's something to do with having an NT server that requires some small change. Ads.dat holds all of the data for the scripts, the configuration data, and the ad data. When using the admin area, saving the config changes writes to file as it should. The problem is when the ad data (specifically clickthrus) changes and the file is rewritten, it omits the config data. I think I've narrowed it down to two smaller problem areas. Click.php, which logs the click and redirects Code:
And then in ads.inc.php Code:
Is there an obvious error here? ![]() Thanks. Posted by admin (Graham Ellis), 30 May 2003 Hi ... welcome ... and exactly the right use of the forum ![]() Educated guess: add the line Code:
before the while (....) line in the writeads function. In PHP, the each function returns a key / value pair from an array each time you call it, and it returns a false value when it runs out of data. So far, so good ... except that when you enter such a loop it starts from wherever it happened to reach last time you used each on the same array last. The frighteningly named "reset" simply resets the internal pointer that each uses so that it starts (again) at the beginning. There are time where you have to do a reset before a loop of each-es, even if you've never eached through the array before. I don't think the pointer is automatically initislised when an array is created. Anyhow - if that's it, great ... if not, let me know and I'll have a further look (I would probably end up suggesting creating an extra temporary file to write variable into to see more about where the failure is occurring ....) Posted by dabbler (dabbler), 30 May 2003 Ahhhh, and fantastic, that did the trick. ![]() Thank you. Now everything keeps displaying properly. It never fails that when I pick up a free script, I have to spend time customizing it to make it work for me the way I'd like, which has been good, I've learned a lot this way. ![]() Thanks again, you're a star. ![]() This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |