Saturday, December 1, 2007

Google Maps Not Working in Internet Explorer, Operation Aborted

This has been bothering me for a while now. This is about the phpGoogleStoreLocator script that I have been working on integrating into a site the past few days. Just when everything was fine and seems to be working properly, it wouldn't function on Internet Explorer. Everytime I open it, it just crashes. I let other people try it and they experience the same thing.

So after googling around I found out that this problem usually occur when you have a script tag inside your tables. This was not the case on my part but I'll be sure to look out for this one. Apparently the solution to my problem is to put the map initialization code into a function say "loadMap()" and attach it to the body tag like this .

Other solutions to the problem if the the ones above still won't work for you are :

  1. Enclosing with a div tag where you want your map to appear. Something like this one : <div id=”map” style=”width: 400px; height: 400px”> and then make sure that all your javascripts are at the bottom of your document below the body tag. Thanks to Ryan.
  2. Moving the map function in the window.onload() handler. Thanks to Justin.
These solution will mostly work but if it still won't try to visit the Microsoft support site here.

Wednesday, November 28, 2007

Slow programming day...been traveling

I just arrived at my parents house today. I came here to visit them until the Christmas season. I've been traveling whole day so no programming for me today. Travel is 5 hours total which consists of 3.5 hours of land travel and 1.5 hours by plane :). I'm going rest for the rest of the day then I will continue programming tomorrow. I'll be back soon to post what I have done.

.... I miss my girlfriend already.. hehehe.

Sunday, November 25, 2007

Exporting mysql data to csv

Today I'm going to discuss the opposite of the previous post. Here it is :

/*some checking here like if the user is logged in, this is important in cases where we don't want other users to get hold of the data*/

//connect to the mysq;
define('host', 'localhost'); //Mysql Server name
define('database', 'dbname'); //Mysql Database name
define('user', 'dbuser'); //Mysql Username
define('password', 'dbpassword'); //Mysql Password
$dbtable = "dbtable";
$connection = mysql_connect(host,user,password);
$db = mysql_select_db(database,$connection);

$sql = mysql_query("select * from ".$dbtable.");

$fields = mysql_list_fields("yourdatabasename",$dbtable);
$columns = mysql_num_fields($fields);
$output = '';

// Put the name of all fields
for ($i = 0; $i < $columns; $i++)
{
$l=mysql_field_name($fields, $i);
$output .= '"'.$l.'",';
}

$output .="\n";

//we now put all values from table
while ($l = mysql_fetch_array($sql))
{
for ($i = 0; $i < $columns; $i++)
{
$output .='"'.$l["$i"].'",';
}

$output .="\n";
}

// Output to browser with appropriate mime type, you choose
header("Content-type: text/x-csv");
header("Content-Disposition: attachment; filename=yourcsvfile.csv");
echo $output;
exit;

?>

This script will prompt for a download for the csvfile named yourcsvfile.csv which contain all the columns and entries from the table dbtable.