Thursday, September 21, 2006

Mysql Error s

Handling mysql errors
http://www.planetmysql.org/entries/4067

Wednesday, September 20, 2006

mysql_db_query deprecated

When you are not programming/scripting alot lots of things pass you by.

PHP since 4.06 has deprecated this function mysql_db_query, that actually I used a lot. Now I like this function as in one function, I pass the database name, the SQL query and the connection resource link which is optional

resource mysql_db_query ( string database, string query [, resource link_identifier] )

Instead they are now asking that we do the following. Two things that could be done in one

mysql_select_db()
bool mysql_select_db ( string database_name [, resource link_identifier] )
mysql_query()
resource mysql_query ( string query [, resource link_identifier] )

The advantage I see is that you can actually check to see if the database is present before doing the query.



if ( ! mysql_select_db (database )){
echo "database not found";
}

All three functions have been available since PHP 3.

snippet of how things change.
Config File
------------------
$dbuser="aaaa";
$dbpass="bbbb";
$dbhost="cccc:3308";
$db="dddd";

$dblink=mysql_connect($dbhost,$dbuser,$dbpass)or die("you have an error connecting your database");
mysql_select_db($db,$dblink);
/*
mysql_select_db($db);; // is ok as the resource link is optional. Function will look for last open resource
*/


Query
----------
$query ="SELECT * FROM TABLENAME";
mysql_query($query,$dblink);
/*
mysql_query($query); // is ok as the resource link is optional
*/


instead of

Config File
------------------
$dbuser="aaaa";
$dbpass="bbbb";
$dbhost="cccc:3308";
$db="dddd";

$dblink=mysql_connect($dbhost,$dbuser,$dbpass)or die("you have an error connecting your database");
/* or
mysql_connect($dbhost,$dbuser,$dbpass)or die("you have an error connecting your database");
*/

Query
----------
$query ="SELECT * FROM TABLENAME";
mysql_db_query($db,$query,$dblink);
/*
or
mysql_db_query($db,$query);
*/
Few extra lines and it is worth it. I will start doing things this way now

References
mysql-db-query.php
mysql-select-db.php
mysql-query.php

Wednesday, September 06, 2006

Centering a Div [Browsers and Quirks]

use tips on DIV model...
http://tutorials.alsacreations.com/modeles/
http://tutorials.alsacreations.com/centrer/
http://www.andybudd.com/archives/2004/02/css_crib_sheet_3_centering_a_div/index.php

Wednesday, August 30, 2006

.jm to be no longer free.

The Mona Information Technology Services (MITS) Department of the University of West Indies (UWI) has decided to charge for .jm domains.

I am happy for this so long as it results in better service, including quicker turnaround time. However I find this statement in the article puzzling.

"The charge for .jm would remain competitive with international rates, as low as US$35 ($2,310) per year, said Samuels."

Internationally the highest rates are US$35 per year in most jurisdictions while costs can be as low as US$2 per year, if not less.

I would like some clarification on this.

There is another statement that is also interesting, although I am not sure they can actually do it what it says. The actual statement of interest is "analysing 'hits' to a given website". The full statement is below.

"Besides registering and administering all .jm domain names, MITS also conducts website research including domain name searches and analysing 'hits' to a given website."

Again clarification on this would be good. Privacy invasion.

Thursday, August 24, 2006

Minimum Character length and MySQL Full Text

Every now and then you come across some nusiance

Mysql Full Text search is lovely but it has some weaknesses. One of which is its Minimum Character length requiremnet.

Happily, the fix is fairly easy if you have access to the .cnf file

Changing the Minimum Character length

1. check what .ini/.cnf your mysql is reading
2. change your my.ini/.cnf like this:
[mysqld]
ft_min_word_len=3
ft_stopword_file="C:\\MySQL\\stop.txt"
3. restart your mysqld
4. reindex your table using REPAIR TABLE tbl_name QUICK;


Useful Resources
http://dev.mysql.com/doc/refman/4.1/en/fulltext-query-expansion.html
http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html
http://mysql.com/doc/refman/5.0/en/fulltext-search.html
http://dev.mysql.com/tech-resources/articles/full-text-revealed.html

OThers
http://jeremy.zawodny.com/blog/archives/000576.html
http://mysql.com/doc/refman/5.0/en/fulltext-stopwords.html
http://www.onlamp.com/pub/a/onlamp/2003/06/26/fulltext.html

Robots.txt and Search Engines

It is not sexy but it useful. The robots.txt is suppose to tell robots/bots/crawlers where they can crawl on a web site. The robots.txt mus...