The most recent posts on spiration http://www.spiration.co.uk/rss/latest The most recent posts on spiration en-us Torkalot christo@uk.com christo@uk.com PHP Parse error: syntax error, unexpected T_SL http://www.spiration.co.uk/post/1430/PHP Parse error: syntax error, unexpected T_SL This is a hard one to spot, so I thought it would be worth posting up here in the hope that it will save somebody some time. The PHP error looks like this: [code] PHP Parse error: syntax error, unexpected T_SL in [/code] One of the things that I regularly whinge at my team in Yahoo! about is meaningful log messages. It really doesn't make sense to log an error if it isn't clear what is being communicated, or what possible course of action an engineer/developer might take to resolve the problem. PHP commonly slips up on this point. There are even cases of errors being logged in Hebrew! In order for an error message to be useful, it should be a) Tagged in some way so that monitoring systems can be hooked into it, and b) it should bear some meaningful information for whoever is likely to read the message. In this case, the fix is simple. The message is probably complaining about a trailing whitespace on the end of a HEREDOC declaration. For exmaple, if your heredoc looks like this: [code] $html = <<<EOT <div>here is some html</div> EOT; [/code] Then you should check after the first 'EOT' to see if there is some whitespace immediately after it. christo Betfair API - php library released http://www.spiration.co.uk/post/1427/Betfair API - php library released Back when I was fiddling with backingline, I spent some time looking at Betfair to see if it would be feasible to take data from Betfair's exchanges and automate a dutch book through backingline's dutching engine. In order for that to work, an application would have to be developed which could talk to Betfair's exchanges, pull current market data, prices and depths on offer, run them through the backingline webservices and represent them to the user. At that point I realised that there is a distinct lack of good PHP API code for betfair, so I decided to write some. The backingline integration became a thought of the past, and a couple weeks ago I sat down and put some proper time into the formation of [url=http://github.com/planetguru/bflib]bflib - an open source Betfair library[/url] The code is GPL's and publically available. There is also a demo app running at [url]http://www.backingline.com/bflib[/url]. I will make incremental enhancements over coming weekends and see where this goes. If all goes well, I might re-visit the backingline integration. SOAP-ERROR: Parsing WSDL: Couldn't load from 'URI' : Extra content at the end of the document http://www.spiration.co.uk/post/1426/SOAP-ERROR: Parsing WSDL: Couldn't load from 'URI' : Extra content at the end of the document This error kept coming up when trying to read the WSDL for a soap service which I was trying to consume - actually when writing some Betfair client classes. The WSDL was definitely valid and well formed and there wasn't any training newline, or superfluous whitespace that I could detect. I thought the issue might have been with the HTTP headers being passed up in the response, but they all appear to be intact. Digging a bit deeper, it turned out to be a bug in PHP itself ([url=http://bugs.php.net/bug.php?id=48216]php bug 48216[/url]). The 'Stream wrappers' within PHP were polluting the consumed file stream with superfluous characters. I have retested against a php-HEAD build this evening, and the issue appears to be resolved. Now awaiting the next point release of PHP so that this can go to production. christo General error: 1030 Got error 134 from storage engine http://www.spiration.co.uk/post/1425/General error: 1030 Got error 134 from storage engine if you get this message in your Mysql powered application, or error log, you are looking at a table corruption, which needs to be fixed using myisamchk. You can do this at the mysql prompt very simply as shown in this example: [code] mysql> check table sessions; +-------------------+-------+----------+----------------------------------------------------------+ | Table | Op | Msg_type | Msg_text | +-------------------+-------+----------+----------------------------------------------------------+ | torkalot.sessions | check | warning | 7 clients are using or haven't closed the table properly | | torkalot.sessions | check | error | Found 2 keys of 1 | | torkalot.sessions | check | error | Corrupt | +-------------------+-------+----------+----------------------------------------------------------+ 3 rows in set (54.76 sec) mysql> repair table sessions; +-------------------+--------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-------------------+--------+----------+----------+ | torkalot.sessions | repair | status | OK | +-------------------+--------+----------+----------+ 1 row in set (0.20 sec) mysql> check table sessions; +-------------------+-------+----------+----------+ | Table | Op | Msg_type | Msg_text | +-------------------+-------+----------+----------+ | torkalot.sessions | check | status | OK | +-------------------+-------+----------+----------+ 1 row in set (0.00 sec) mysql> [/code] So in this case, there appeared to be 3 issues reported by the check tool - there were 7 cases of clients which had opened the table, but not closed it properly (presumably not releasing locks on disconnect probably due to an unclean shutdown). I'm guessing, but probably the 'Found 2 keys of 1' would suggest a duplicate primary key situation. Anyway, running the 'check table' and 'repair table' commands will save your day. You could equally run myisamchk from the command line. christo Hiking to Laza, Azerbaijan http://www.spiration.co.uk/post/1424/Hiking to Laza, Azerbaijan 8th Aug 2009 Hiking to Laza, Azerbaijan flickr:3822757566:left flickr:3822759198:right We woke to calm and allowed the sun to dry the tent before packing it up. Breakfast consisted of bread, cheese, cucumber and tomato, with apple juice. We were quite late and it was nearly noon when we moved onward. Our hike took us in a north easterly direction, away from the foot of Şahdağ and up the valley of the Shahnabadchay river. This is surely the true 'Cloudcatcher Canyon'. In this tight valley, the clouds form all day long in the form of a long whispy serpent around the base of Mt. Şahdağ. They also drift down the east side from Baltagaya and can quickly throw the Shahnabadchay valley into mist on an otherwise clear day. The scene is really gorgeous. Everywhere mountains compete to dominate the horizon. Everywhere clouds and mist swirl and subside, constantly cycling around the foothills. In the expansive pastures below, sheep are herded throughout the four months of summer and shepherds live semi-nomadically with their families in just two or three small camps. flickr:3821952831:left It was 30 minutes into the Laza leg of our hike that we came across one such camp. As we crested a hill, we saw the large blue tent constructions below us. it was guarded by dogs, of course, but a young boy came up the hill and greeted us. He kept the dogs away with his stick and walked us down to the camp, where we met his family. His grandmother was sat in one tent making bread. She was rolling dough and cooking it on a flat circular slab over a fire. She was smiling and was very happy for us to watch and even to have some bread. She handed us two folded sheets of freshly baked, warm lavash. The young boy's dad and brother arrived. flickr:3821953855:right I greeted the dad, answering all his questions and then we talked a bit about their life. He explained that they live in their tents for four months of the year until the end of August, which is when they return to the village. He told me that they feed the dogs on bread and meat. Sometimes they kill a sheep and feed it to the dogs. At night they bring their sheep back to the camp. During the day, the young men take them out to graze on the mountain slopes. Their summer camp was well equipped with a handful of large blue tents. They had hens, which had their own coop built from turf and boards. As we moved on, the man ordered his eldest son to escort us away from the dogs and to show us the direction for Laza. It was a fairly straightforward hike to Laza, although much harder than the first leg, due to the route and the conditions. We followed barely visible sheep and horse trails, at times traversing tributaries to the Shahnabadchay river. Şahdağ soon passed out of sight and points of reference for compass work became fewer. All the way, however, we had the bellow and roar of the river, charging down through the valleys towards Laza. At times the fog would thicken, reducing visibility to just a hundred meters or so - such is the weather in this region. It can change within just minutes. A good 1:100000 map and a compass are just about essential. We had a few stops to eat, or just to catch the views, then made a final slog up to Suvar and then on to Laza. As we walked into the village of Laza, the fog thickened, but not enough to conceal the bright pink village store with the words 'Laza' and 'Market' blazened across it. Outside, Khalid, the village teacher, store owner and hotelier was hanging out with a couple of friends. He greeted us and offered us a room in his house for the next two nights. From then on until our departure, we had soft matresses, hot water and a constant supply of çay and food, which was ejected from the kitchen at fairly regular intervals. Khalid has two children. One son, who has a love for reality TV and çay, and one daughter, who spends her entire time taking orders from her brother. The house had other family guests staying. The women all remained concealed in one half of the house and only ever came out when one of the men ordered tea, or food. It was quite uncomfortable to sit at the table and watch a sixteen year old boy shout orders over his shoulder whilst watching TV and then completely fail to acknowledge the arrival of food and drink at his table. flickr:3821971401:right The men of the family are responsible for running the village shop, which is just outside the house. Customers arrive either on foot, or on horseback and yell until somebody arrives to unlock and serve them. Meanwhile, the mother busies herself with laundry, cleaning and milking the three cows. With what remained of the evening, we took a look around the tiny village of Laza. There really isn't far to go, so we walked slowly, photographing sheep and the mosque which emanates a dull shine from its roof through the perpetual mist which swills around the valley. Hiking from Xınalıq to Laza, Azerbaijan http://www.spiration.co.uk/post/1423/Hiking from Xınalıq to Laza, Azerbaijan 7th Aug 2009. hiking from Xınalıq to Laza, Azerbaijan flickr:3822745418 We had breakfast with Fa'ik in the guest house kitchen. He gave us fresh milk from the family cow. We shared cheese and bread, washed down with a pot of tea. On leaving, Fa'ik handed me a stick to ward off sheep dogs whilst hiking. As we left a group of local kids were just making their way to school. They had bits of paper scrunched into their pockets or tucked into their trousers. We chatted with them for a short while before moving on. Of course we had to pass through the military checkpoint. The four young soldiers took great delight in picking through all our gear, taking each item in turn and asking questions. Their primary aim was to bag some souvenirs and they asked for food and drinks. In Matt's bag, they found a watch, phone and a GPS logger doobry. Each time they held the item up, saying 'souvenir?', to which we said 'no' and they carried on searching. One of the soldiers found a tube of hand sanitiser in my pack. I explained to him what it was for and he couldn't resist squirting some onto his hands and assessing the result. At one point, Matt was overcome by a surge of uncontrollable generosity and after a bit of hassle, handed one of them twenty dollars. Of course I wound him up about it afterwards. flickr:3822743170 With everything repacked, we were granted passage and made our way through the barrier and into the mountain hinterlands that awaited. About one hour into the hike we were summoned by a man on the hill to our left. He was sat with a friend and a girl, who was cooking some food over a small fire. They offered us tea and we chatted about their work. Of course they had lots of questions. I had plenty in return. We ate together and drank tea for a while. The men were tough, but friendly enough. The girl never spoke, but concentrated on keeping the samovar hot and ensuring that every plate had some food. The men went back to work and we continued with our hike. flickr:3822749414:right In total we were hiking just five hours before we reached our stop. The route to the West of Xınalıq is a reasonable condition track, easily passable by 4WD. We took some short cuts and stopped occasionally to refill our water containers at springs or streams. The inclines were pretty hard work - especially with 20kg or pack and water. Occasionally we were passed by men on horseback, making their way between their shepherd camps and Xınalıq. At around 5.30pm we reached the practically infinite meadows at the foot of Mt. Şahdağ. The scene is out of this world. At the bottom of Şahdağ, clouds force their way through a canyon and attempt to hug the base of the mountain. In all other directions, mountains fling themselves to the sky, collecting a permanent show cover at their peaks and down their Northern faces. We stepped down onto the immense rolling pasture and looked for a place to pitch the tent. With everything set up, I went to sleep in the sunshine. Matt was watching the shepherds far in the distance, flickr:3822754764 keeping a close eye on their dogs. The sheep dogs in these mountain regions are enormous, savage beasts - more like wolves than conventional sheepdogs. They are extremely aggressive and they need to be. Matt woke me up when a pack of six dogs started running in our direction. We watched cautiously. They stopped on the opposite side of a ravine, looking and barking in our direction. We couldn't figure out what they were looking at until Matt turned around and spotted three more massive dogs running towards us. I have never seen Matt move so fast as dived head first into the tent shouting 'dogs behind us!'. I dived in alongside and quickly zipped up the front. we were trapped. Gradually the two packs approached each other, meeting in the ravine below our camp to exchange growls and maneuvers. They snapped and snarled at each other, intimidating their adversaries and never quite descending into total warfare. Eventually they backed off and returned to their flocks, apart from the nearest pack, which turned on a small group of cows, aggressively bearing down on one of them until it was singled out and pinned against the mountainside, snorting and flailing pathetically at the cascade of teeth around its legs. A shepherd eventually appeared and nonchalantly moved the cattle away, sending the dogs back to their flock. We embarked on collecting combustibles for a fire. With no trees in the area, we were limited to thistle roots and dried dung, but with two sticks, which Matt found on the hill behind our camp, it was flickr:3821949321:right sufficient to boil water for our noodles and also to boil up a pot of buckwheat, which we ate with half a stock cube crumbled up in it. Whilst we were eating we were joined by a couple of shepherds. They had three dogs with them and held them at bay with sticks whilst we chatted. After realising that we didn't have anything exciting to offer them, they went back to their 1800 sheep. We finished eating, washed everything and watched the sunlight fade before going to bed. As we were settling in the tent it started to rain. By 10pm we were in the midst of an enormous thunderstorm. The rain lashed at our tent and lightning danced around the mountains. For a short while I felt quite exposed in an aluminium framed tent right in the middle of a vast pasture. The scene was pitch black outside and the balls of lightning were blinding us - I tried to observe the storm through a small gap in the zipper, but eventually gave up and settled for counting the seconds between flash and crash. When the gap increased beyond a second, I started to relax and as the storm rolled through, we went to sleep. Atəşgah and Xınalıq, Azerbaijan. http://www.spiration.co.uk/post/1422/Atəşgah and Xınalıq, Azerbaijan. 6th Aug 2009. Atəşgah and Xınalıq, Azerbaijan. flickr:3821916359 We started the day with breakfast and the usual tea ritual, then got ready for a hike to Atəşgah. Fa'ik led the way out of the village up to the checkpoint about twenty minutes to the West. A couple of soldiers held us back, checked over our passports and radioed our details up to the base station a mile or so up the hill. The walk took us along the river for a further twenty minutes at which point we left flickr:3822724414:right the track and hiked North. We continued to pass people who were busy cutting the grass and raking it into stacks. The walk got harder as we started to ascend a steep grassy incline, eventually meeting with a sharp rocky ridge, which led us on to a further climb over silty shale scree. With the Kyzylkaya mountain straight ahead we followed the Eastern contours of a final peak until the valley opened up to our right. Below us was a small circular pile of stones from which the mysterious natural flames were burning. We went down and watched for a while. I was getting slightly annoyed by some French dude who had followed us. he had a whole catalogue of issues with transport and accommodation. I tactfully suggested that he should head back to Quba and that I could arrange transport. He took up the offer and later that afternoon I called Ramazan and negotiated a price for him to come and collect a passenger. flickr:3821924301:right Matthew was sick in the afternoon. he had diarrhoea and nausea, so it seemed best to keep him hydrated and let him sleep. Meanwhile, I went out and spent time with Fa'ik. I asked him about his work and the haymaking. He told me that by the end of August, all the cut grass will have been dried, stacked and then carried back to people' homes in time for the start of Winter in early September. Fa'ik asked me if I had a horse back in London. I told him that London is a bit like Baku - we just use buses and the underground. He let me have a try at scything a patch of grass. It was not easy. I had three feeble attempts, but found it hard to get the right combination of speed, height and orientation of the blade. I left Fa'ik in the field and walked back up the hillside to the village to get some basic supplies from the shop. flickr:3822734594 Coming back through the village from the main shop, I stopped to look at a wooden house, which on closer inspection turned out to be another shop - much smaller and much more interesting. I climbed the wooden staircase to the entrance and greeted the old man inside. We chatted for a while. His name is Taptuk and his shop is something to behold. Selling everything from vodka and fish to childrens' toys and clothing, the whole area occupies perhaps 10m2. Taptuk has to climb over the counter in order to open cupboards and present the best of his wares. He even has a little note book for guests to jot some memos. I added some sentiments, then bought some fruit juice before thanking Taptuk and leaving. flickr:3821925751:right Further through the village I encountered a lady cleaning large quantities of wool. She filled one of the water troughs full with wool and let the water flow in to fully soak it. She then coimbed up and started mashing the wool with her feet, as if crushing frapes to make wine. She wore blue wellies and carefully liftered the bottom of her skirt to keep it dry. I watched for a short while, concious of the protocols of the region which prevent contact between women and men outside of their own family. Back at the guest house, I watched Fa'ik working. His wife and sister passed occasionally and squawked at him down the hillside. The language of Xınalıq is unique, with no resemblance to anything I have heard elsewhere. They have hard clucking sounds which they emit from their throats. It isn't something I can reproduce and nor do i have a recording. Matt woke up and we went for a hike to the caves North of Xınalıq. Dropping downhill from the northern tip of the village, we passed a further small-holding, with hens and donkeys. A woman was making fuels bricks by the stream - taking dung from the animals, moistening it in water, rolling it into balls and flickr:3822738088 then flattening them against the rocks to dry in the sun. We walked up steep inclines, gradually picking our way over to the caves, which ultimately turned out to be fairly uninteresting, but the route offered stunning views back on the village, presenting it as a complex jumble of dark stone houses, almost floating between soaring mountains. As the sun started to drop behind the Western peaks, we made our way back down, followed by several cows, which somehow instinctively knew that it was time to go home. Back in the village, women milked them and tethered them up for the night. Meanwhile shepherds returned with their sheep. In all directions, sheep and cattle were coming home - accompanied by women, children, men, or even on their own. Our day ended with more encounters with tiny kids, who played with our cameras. I gave them Smarties and they ran away. We slept to the sound of the river at the bottom of the field and a dog barking in the distance.