IGN announces best games of 2008
[ December 30th, 2008 ] Posted in » Otakuism, Video games

Seeing as I only care about the PS3, here they are:

Metal Gear Solid 4 has won a number of awards: Best action, Best Graphics and it was named PS3 game of the year.

LittleBigPlanet won a few too: Best platform, Best artistic design and many others.

Best fighting: Super Street Fighter II Turbo HD Remix
Best music: Rock Band 2
Echochrome
Burn out Paradise
Best RPG: Fallout 3
Best shooter: Resistance 2
Best RPG: Valkyria Chronicles
Best original score: Eternal Sonata

I’m not exactly a fan of Resistance - played multi player at a friend’s house many moons ago, but I didn’t find it all too impressive. Also, I’m not a fan of Eternal Sonata - played the demo, but didn’t find it all too interesting.

Do wish they a reward for “Most exciting,” which of course would go to EndWar. Seeing my infantry trying to fire back at the enemy while tank shells raining down on them is too much to ignore. Definitely not the best strategy (Rock-Paper-Scissors type combat), but most certainly deserves something. Maybe it’s in another list?

Btw, Persona 4 won best PS2 game of ‘08 - w00t!

Can view the rest here. Do you agree with the list?

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Delicious!….hmmmm, yes!!!

This video explains what the title means. Anyway, one of the things I hate about PHP is how redundant the MySQL statements are. Each one is the same thing, but different only by a little bit. Experiencing the same thing? Well, this function I just wrote will help lighten the redundancy!

<?php

function add_mysql_entry($info)
{
if(is_array($info) and sizeof($info) > 0)
{
// Python: mysql_values,mysql_tables = {},{}
$mysql_values = array();
$mysql_tables = array();
if(is_array($info['post']))
{
foreach($info['post'] as $post)
{
// You need single quotes, or else it’s a suntax error.
$mysql_values[] = “‘”.htmlspecialchars($_POST[$post[0]]).”‘”;
$mysql_tables[] = $post[1];
}
}
if(is_array($info['background'])) {
foreach($info['background'] as $background_info)
{
$mysql_values[] = “‘”.$background_info['value'].”‘”;
$mysql_tables[] = $background_info['column'];
}
}
$mysql_values = implode(’,', $mysql_values);
$mysql_tables = implode(’,', $mysql_tables);
$query = mysql_query(”
INSERT
INTO “.$info['table'].”(”.$mysql_tables.”)
VALUES(”.$mysql_values.”)”) or die(mysql_error());
}
}

?>

This function is basically a simple MySQL INSERT statement. It makes it so that you don’t have to declare each $_POST variable, preform all precautions, execute the query, and then make sure that the query did what you wanted it to do. Here’s an example:

<?php

$info = array(
'table' => 'shoes_tb',
'post' => array(
array('add_shoes_name', 'shoe_name'),
array('add_shoes_desc', 'shoe_desc'),
array('add_shoes_price', 'shoe_price')
),
'background' => array(
array('value' => date("d/m/Y"), 'column' => 'shoe_date_added')
)
);
$add_shoe = add_mysql_entry($info);

?>

In this example, there are three $_POST variables that the programmer wants to use: add_shoes_name, add_shoes_desc, and add_shoes_price. He wants insert them in the columns shoe_name, shoe_desc, and shoe_price in the table shoes_tb. Of course, getting something such as the date and not letting the user see it can’t be done through a $_POST variable (other than using the hidden input type). This is where background comes in. The syntax of the $info array is:

<?php

$info = array(
'table' => the MySQL table's name,
'post' => array(
array(input_field_1, column_name_1),
array(input_field_2, column_name_2),
...
array(input_field_n, column_name_n)
),
'background' => array(
array('value' => value_1, 'column' => column_name_1),
array('value' => value_2, 'column' => column_name_2),
...
array('value' => value_n, 'column' => column_name_n)
)
);

?>

All in all, this is function is delicious.

September 1st, 2008 | 2 Comments

One thing you should NOT do with PHP

I know how dangerous it is, but it’s out of habit. What am I talking about? Well, it’s probably one of the most common mistakes a PHP developer/programmer/user will find: an array in a loop. It happens to me all the time, no matter what I’m working with, let it PHP, Python or JavaScript. This is just a reminder to me and anyone who faces this problem: never build an array in a loop! The array will just overwrite itself, and it can be a very well hidden problem. This includes loops and nested loops (loops in loops)… unless you want the array to overwritten. There are instances where the array needs to be overwritten (the mysql_fetch_assoc function is a good example).

This whole post may sound silly, but I suggest you be careful with array building in loops! it won’t cause any major problems (with exceptions), but you will never get the result you want (unless you want to the array to be overwritten, like I said before).

Drieick

August 18th, 2008 | Leave a Comment

Powered by WordPress | Blue Weed by Blog Oh! Blog | Entries (RSS) and Comments (RSS).