Thursday, September 21, 2006

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

Audio Noise Removal

Many times in record clips we end up with unwanted background noise. Recently faced with the situation, I  needed to clean up some audio and...