[Work] PHP/MS-SQL c onnect problem

Here’s one for the PHP webnerds out there:

PHP/SQL7. At the start of every script, I include db.php which contains this:

$db = mssql_connect(‘devbox’,’foo’,’bar’);
mssql_select_db(‘[devsitedb]’, $db) or die (“Couldn’t open database connection”);

And then I pass that connection into the various classes and functions on the site. Fine and dandy.

However, in the course of one fo the scripts for this site, I need to hook into a second database temporarily, so I do this at the appropriate point:

$second_db = mssql_connect(‘devbox’,’jim’,’bob’);
mssql_select_db(‘[anothersitedb]’, $second_db) or die (“Couldn’t open second database connection”);

Then do what I need to with that connection and close it with mssql_close($second_db);

Here’s the problem, though: despite the fact that the two connections are clearly different, the second one is overwriting the first, so that when I come back to doing things with the first connection, it now can’t find any of the stored procedures i needs. This is true at any point after $second_db is opened, and it make no difference whether or not I close $second_db. The conenction is just being over-written.

At the point of opening, print_r($db) returns “Resource id #2”. And that holds true for the second connection as well – print_r($second_db) also returns “Resource id #2”.

mssql.max_links is set to -1, so there should be no problem with the number of connections that I’m making…

Obviously, I would like it if this didn’t happen, and $second_db become “Resource id #3”, thus allowing me to juggle the two connections as I need to.

Anyone out there had similar problems, or able to spot what I’m missing?

What’ve I been doing lately?

Well, it’s December, so obviously, it’s time for the heavy drinking again. Spent the first part of Thursday night at Albertine in Sheperd’s Bush. Bit full of BBC types, but after three quarters of a bottle of Australian red (the name of which escapes me, which is annoying, because I’d happily buy it again) I cared a lot less. Might try and get back there – the wine list looked interesting, and the food sounded like it’d go well with the wine…

Quiet night in Friday night, and then out for drinks with davebushe, daveman23 and seanazz last night, which were just what the doctor ordered, I think. Sadly, the slight hangover combined with the first trip to the gym in a couple of weeks has left me more or less unable to move.

I rewatched the first episode of The Prisoner this morning. It’s dated very strangely, that show – it’s unmistakably of a certain era, but because of the very stilted and stylised atmosphere in the village, it gets away with it surprisingly well, and it sort of feels like the sixites/seventies decor is just another part of the strangeness of the setting, rather than a sign of aging. Why do I suspect that the upcoming remake won’t be half so clever?

My Brains, They Are Loathsome

I have had a very pleasant and relaxing weekend. Just what the doctor ordered. Many thanks to all the lovely humans that helped me unwind.

My brains get no such thanks.

I had hoped to wake up this morning refreshed and ready for another week of work, but no. Whatever I was dreaming about, it cannot have been good. I woke up, half an hour early, curled up in staggering tension. Not in fear, or panic, or anything one might get from a nightmare, but rather the kind of tension that you find yourself in when you know something is about to kick off, and there’s nothing you can do to stop it, that tense, wary, ready to hurt something tension that you can feel up and down your spine and across your shoulders.

So much for relaxed and refreshed. Still, if anyone tries anything on the tube, I’ll be ready.

Bastard brains.

Google Base

Well, it’s interesting. I’m going to have to sit and play with it properly at some point, but it’s certainly an interesting idea. One thouht occurs: it’s a move away from social networking, back to a more web-tradtional approach – the idea here is not that you share content with a taste-tribe or a network of friends, but that you make it available to everyone.

I understand why Google themselves might want this: they’re getting structured data for free, that they can use to make themselves the first port of call for anyone looking for any information ever (and if you aren’t frightened by Google by now, you really should be). But like many others, I don’t see where the incentive for the public to use it is. What value do I derive from putting a copy of the content on here into their “news and articles” database?

I can in fact, see the potential value for a large corporation, from a marketing perspective, and I note that Google Base will take bulk RSS/Atom uploads of content, so in fact, and a reasonably switched-on operation should be able to dump data in there quite fast, but still, I wonder why they’d bother – surely Google will index their web content anyway?

I suspect that this is either another daft experiement, like Orkut (OK, yes, most of Brazil are on Orkut. No-one else is.) or the start of a larger plan for Google.

This entry was originally published at my workblog.

Links For Monday 7th November 2005

This entry was originally published at my workblog.

Links For Thursday 3rd November 2005

This entry was originally published at my workblog.