So I have been creating lots of new features for me to maintain my cocktail making website. One feature has involved me setting up a new mySQL 5.0 database (with cool stored procedures I am only starting to understand now) in order to do some tracking of what is happening on the site and with my widget. This has required me to use two databases at once for the first time. One to check if a user is signed in with admin rights and the other to check the tracking out of the other database (php security is really tricky so I am slightly nervous posting even this here :s ).
However I did want to note how you close a connection with a mysql database using PHP in order to open one with another mysql database since it's really simple but I found it hard to get info. Here is an example (with $hostname, $username, $password and $databasename containing what they are named):
<?php
$link = mysql_pconnect("$hosturl", "$username", "$password")or die("Could not connect: " . mysql_error());
$db = mysql_select_db($databasename,$link)
or die ("Couldn't select database");
?>
mysql_close($link);
So when you open databases try closing them, I know I will in future for good practice, it makes everything much simpler if you add another database at a later stage.
Graphing Search Result Numbers Over Time
So I have had a random idea for a little project that could be fun. We all know about Google Trends, eBay Pulse, the Overture Search Suggestion tool. Now I think all of these are truly amazing tools. Something we don't neccessarily know about is the supply side of this equation. All of a sudden that is really interesting me. It would be relatively simple to set up a CRON job that runs once daily and pulls the abundance through the various API's available. It could also be really fun to see how trends shift over time (perhaps looping in Technorati and a couple of other sources). It could even be a fun tool for an eBay seller to help me monetize it a little bit... hmm I think I may build this at the weekend and if I do I will post the resulting graphs on this blog as well as on a little site I recently purchased with 1 and 1. YAY!
November 13, 2006 in apis, general comments, php | Permalink | Comments (0) | TrackBack (0)