(há uma versão portuguesa desta entrada)
Last night I was writing some PHP code – a simple upcoming feature for the blog – when i had to once again query the MySQL server, and use mysql_fetch_array() to grab the returning data. Some of you probably use some fancy PHP Class to interface with the server, and you should. But for some odd reason i prefer to do this way.
So, i end up having an array – which i usually call $raw – with a couple keys and values:
Array
(
[id] => 1
[field1] => test
[field2] => another test
)
Now, if you want to use this in a string, you either echo it like:
echo "this is the value of field1: " . $raw["field1"];Or you stick it in a var and use it directly:
$field1 = $raw["field1"];
echo "this is the value of field1: $field1";
Ok, but most of the times you're simply creating a local variable with the same name as the key. So I came up with a very short function to pull out the variables from the array. It can also be useful to extract session variables, but it can be used pretty much in every similar situation.
function pull_vars( $target ) {
foreach( $target as $key => $val ) {
global $$key;
$$key = $val;
}
}
Attention This can cause some clash between these and other variables. Be careful with the names of the variables used. If this happens, you can solve it by giving an alias to the fields in the MySQL query: $sql = "select title as ptitle, datetime as dt, (...).
Stick this in a file called pull_vars.php. Now include it on top of every page and call it every time you need to unpack the variables in the array returned by the MySQL server. Just for the sake of completeness, here's how you call the function:
pull_vars( $raw );
Thought i'd share this little tip, might be helpful to some of you. ;)
Last wednesday, i had the pleasure of being one of the lucky bastards that attended the pre-screening of Serenity in Lisbon – thanks to a hard-working
Right from the beginning i realized they were going to explain everything so the people who hadn't seen the tv series would understand the story and enlightening us – the fans – on several issues while they're at it. So for all of you who are dismissing this movie simply because you haven't seen any episode, think again, because the odds are you'll like it – i haven't heard a negative opinion on this movie. And if you're one of the fans, i don't need to tell you to go watch it, but i will tell you it didn't disappoint me — at all.
Last year, a
Ron Howard and Russell Crowe meet
Some of you might remember one of my ![meebo in action [meebo in action]](http://imgs.andr3.net/meebo_inaction.png)


At first i was surprised that they had a full live show of Andrew Bird available as a 500kbits wmv stream – amazing quality, if you have broadband. there's also a 56kbps stream for dial-up users – , which i devoured happily. It was after that when i realized how BIG their list of available shows was! They're featuring 380 full live shows – and counting! – recorded mostly at the
The php coder inside of me felt impatient, mainly because I hadn't seen any mysql tables from Mint, but i had from ShortStat. I knew
I found a very good
At last! The long awaited Tim Burton's adaptation of Roald Dahl's wonderful book that has inspired children throughout the years has arrived. It's been out for a while, but i only just got around to see it. The expectations were very high, mainly because the dream team got together again; Tim Burton, Johnny Depp and the musical genious Danny Elfman.
Everyone's talking about
If all you want is a very light messenger, then Google Talk is the Instant Messenger for you. If not, there is always the overlooked
I had to start sometime, given my past experiences with Javascript, but i had to get some stuff out of the way first – namely, this website – so that i could dedicate an evening messing around with this new technique – not technology – without other stuff in my head.
You can now comment without being registered, but i still strongly suggest you to register. Why? Well, you will loose your navigation preferences every time you close your browser. If you have an account created, you can choose to auto-login which will load your preferences from your 

I had some expectations about this movie, since i saw it on Leno a couple weeks ago and the clip left me mouth-watering. It didn't seem to have that much of a story at first, but the performances of the actors were pretty outstanding in the clip – as well as in the trailer – so i was left a bit curious about the whole deal.