Friday, January 29, 2010

Database handle in PHP-mysql

This is the two line code i use to connect to database through PHP:

$dbhandle = mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

The great thing about this code is that once dbhandle is created then any call to mysql_connect will reuse the old dbhandle. This is very nice abstraction provided by PHP-mysql connector. I dont know if this is same with other connection object or not...

SJ

Thursday, January 28, 2010

A brief on web related technology

http://sharat.wordpress.com/
This page explains some of the web concept in brief ...
Some of them are useful...

SJ

After a month

Sorry i was on vacation lately so had nothing much to post...

Recently i was working on database part of my project...
I had a doubt about auto-increment primary keys that what happen if some fields are deleted in future {which will happen in 99.99% of scenarios } then primary key does not remain sequential and those gaps will never be filled and eventually when project scale heavily then auto-increment field will reach its maximum and project will crash...

I discussed it with friend and in his opinion, auto-increment field is automatically taken care by the database so nothing to worry,... Moreover one should keep in practice to not write program to access primary key sequentially.

He also mentioned that i could use LDAPs for authentication of my system...
Will write rest later...

SJ

Sunday, December 27, 2009

DOJO Charting and php mysql connection thingy

yesterday i was trying to get my ajax-php-mysql code working..
Following are the problems that i faced...
1. I wanted to avoid call to mysql_connect method multiple times because in my perception, this would lead to multiple handles to database and hence wastage of resource and time... I was trying to save the handle of database in $_session variable but it was fruitless because i was getting server side error that database not connected ... then i checked documentation of mysql_connect and it says that if same arguments are passed then no new connection handle is created.... This can be great abstraction as PHP does the job for you.. but some inflexibility as well that it does not allowing me to have multiple connection to back end.... but i guess my knowledge is incomplete so will update this space regarding flexibility issue...

2. JSON object parsing...
we can use many inbuilt functions... My understanding of this is still vague... I was sending text/plain data from server and calling JSON.parse($data) thingy to convert it to JSON object but in some cases i saw that data was received in JSON format.. means it was converted into JSON on server side itself...
basically read the data from server and store it in {"" : [{"":"","":""},{"":"","":""}] } form....

3. Third problem was related to DOJo charts...
there is no way in dojo charts to create custom labels.. which is bad... because my RA guys would be mad about it...

4. Ajax.. PHP... MYSQL.. JSON...AJAX handling... this is the sequence of getting this done...

For dojo charting quickcet source is ...
http://www.sitepen.com/blog/2008/06/16/a-beginners-guide-to-dojo-charting-part-2-of-2/
first and second blog here... best

SJ

Saturday, December 12, 2009

C pointers notes

http://www.ibiblio.org/pub/languages/fortran/append-c.html

This is also good... read it whenever u are confused

Thursday, December 10, 2009

Post about unix file system working

http://people.csail.mit.edu/rinard/osnotes/h13.html

Read this some time in detail...

Monday, December 7, 2009

i18n support for images and variable size text

http://www.alistapart.com/articles/slidingdoors/

I am struggling with i18n support thingy... so here it goes....

This page explains different ways of sending data between forms or pages...
1. URL
2. Form submit
3. Cookie transfer
http://www.plus2net.com/php_tutorial/variables2.php
SJ