How to enable showing queries in Code Igniter profiling?

Its been now a while using CodeIgniter (PHP Framework), but i have been keep finding new stuff when face some dramatic problem. I have to enable a profiling in one my work and come accross a problem that profiling not showing any queries even database is selected.

To solve this problem goto system/database/DB_driver.php look for :

var $save_queries    = FALSE;

Set save_queries variable from FLASE -> TRUE so your new settings will be:

var $save_queries    = TRUE;

It will now show a queries into profiling. 🙂

How to generate pdf from html using php

I have been working on generating pdf using php. I was using ezPDF which is free, but not that much good. It is always mind stretching and panic to generate pdf by using free libraries. I was looking for a way that can generate pdf from html directly. Thre are many way to get pdf from html by means of generating ps files then ps to html.

There is only one good solution which can easly generate pdf from html is tufat’s html2ps and html2pdf.

Its free and amazing, Download It Free | Download the Developmental v.1.9.6

Note: If you are using html2pdf, you will find that if you use render image option enabled with fpdf selected, sometimes you will get the page not found error. if you not select image render option then pdf generate just fine. To solve this problem, download output.fpdf.class.php and replace with your existing one.

Enjoy your pdf generation from html and don’t forgot to thanks for such excellent work.

How to Generate Unique Auto Number with PHP & MySQL?

There is a always needs of generating unique number for various type of situation in any kind of development from shopping cart to guest book in all possible type of applications. There are so many ways to generating unique auto number in PHP. You can always use php random functions along with the time function to get the unique number.

If you are not so want to perform so much functions and length process on getting unique number, you can always use simple method of getting unique value with the use MySQL.

We can get a unique auto generated number from MySQL by creating an auto incremented field. MySQL will generate a unique number by incrementing the last number of the table and will automatically add to the auto incremented field. This is the best way to generate a trouble ticket number for a help desk system. In a school if a new student joins then all details of the student we can feed to student table and while using the insert query, MySQL will add one auto generated unique number to this auto incremented field. We need not have to specify any thing in our query while adding the auto incremented field data. After successfully adding the record we can get this unique number by using mysql_insert_id(). Now let us try how to create a such auto incremented field.

We have to make auto increment field integer ( obvious ) and also unique. The property set to auto increment. Here is the sql to create a autonumber table with one auto increment field to assign one unique ID.

CREATE TABLE `autonumber` (
`id` int(13) unsigned NOT NULL auto_increment,

This will create one table called auto number starting with next auto number 1049. So when ever you need to get the new auto number or unique auto number value you have to just use insert query like this in your code:

Insert into autonumber (‘id’) values (‘’) or die (“MySQL Error:”.mysql_error());

This query will insert next number 1050 in to autonumber table.

You can get this newly generated auto number by the following function.

$New_AutoNumber = mysql_insert_id();

You can even combine this number with number generated with the time and random function to get more unique value.

Let me drop comment if anyone of you encounter problem in getting it?