It’s Suck!
January 30th, 2008
yeaa..i’am crazy.. i don’t know what i say.. and what must i say…
i’am not sure what i say to you!
My Bad English so Suck..!!!!!!!!!!!!!!!!!!!!!
I Want to share my brain content, state my hearth content….
I Hate to use translator program forever…. SUCK@!!!!@##%
I Don’t care your reaction if you listen to my speak!
I Hate you! If you heed me!
Fuck you alllll……….!!!!!!!!!!!!!!!!!!!!!
Unable to open something.tmp
January 16th, 2008
Weww… i got stressfull today when i start to trying SWFUpload for
handling my files upload nicer, interactive, and informative. I just want
my files upload tasks act like a desktop application, that no need
page refresh. Yeaah now u know what is SWFUpload used for. And i will
not explain more in detail about SWFUpload because this is not thing that
i want to talking about, and i will talking about SWFUpload
in another article if i has been familiar with this great uploader. Soon!
trust me.
Umm.. what i want to talking about now is error message that
say like this : ” Hey! i unable to open or move blablab.tmp in
\yourdir\yourphp_tmp_session_dir\blabla.tmp blablabla”
wtf?! i guess you will checking out your php.ini and go to
session.save_path and make sure if its value is correct.
I got this problem when using all in one web development package. That
is xampp. And i’am not sure if you will deal with something like my problem
maybe your server is good configured. yeaah just for documentation
if someday i meet with same problem like this.
Ok what kind of things you need to configure?
1. php.ini
make sure your php.ini configuration variable below :
session.save_path is correct
upload_tmp_dir is correct
ok enough deal with that two variabel configuration
2 httpd.confg
you need to add this new rule in httpd.conf
add this lines :
<Directory “driveLetter:/path/to/your/saved/tmp/session”>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
what’s next? hehehe guess by yourself.. ![]()
dbo_source Bug Fixes in cakePHP 1.2.0.6311-beta
January 4th, 2008
Today at 06:00 PM when i learning new version cakePHP framework, i want to implement ACL feature. After reading some tutorial, i start to doing each steps explained by the tutorial.
I run this command, in my dos console :
cake acl create aco / ROOT and got error messages like this :
Fatal error: Undefined class name ’string’ in D:\tohtdocs\MyBand\cake\libs\model
\datasources\dbo_source.php on line 1456
This error message annoying, after asking question everywhere, i’am still stuck! no solutions. After that, i decided to visiting all of my new friends in #cakephp at IRC. Hooorraayy i was very luck because i meet very great people AD7six . He ask me for checking cake trac and ask me browse the dbo_source.php in
THE BUG FIXES
The db0_source.php bug is not too serious.. just adding this line :
uses(’String’);
at the top of all classes from dbo_source.php
looks like this :
- <?php
- /* SVN FILE: $Id: dbo_source.php 6311 2008-01-02 06:33:52Z phpnut $ */
- /**
- * Short description for file.
- *
- * Long description for file
- *
- * PHP versions 4 and 5
- *
- * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
- * Copyright 2005-2008, Cake Software Foundation, Inc.
- * 1785 E. Sahara Avenue, Suite 490-204
- * Las Vegas, Nevada 89104
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @filesource
- * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
- * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
- * @package cake
- * @subpackage cake.cake.libs.model.datasources
- * @since CakePHP(tm) v 0.10.0.1076
- * @version $Revision: 6311 $
- * @modifiedby $LastChangedBy: phpnut $
- * @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008) $
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
- uses('set');
- /**
- * DboSource
- *
- * Creates DBO-descendant objects from a given db connection configuration
- *
- * @package cake
- * @subpackage cake.cake.libs.model.datasources
- */
- class DboSource extends DataSource {
and the new with bug fixes look like this :
- <?php
- /* SVN FILE: $Id: dbo_source.php 6311 2008-01-02 06:33:52Z phpnut $ */
- /**
- * Short description for file.
- *
- * Long description for file
- *
- * PHP versions 4 and 5
- *
- * CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
- * Copyright 2005-2008, Cake Software Foundation, Inc.
- * 1785 E. Sahara Avenue, Suite 490-204
- * Las Vegas, Nevada 89104
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @filesource
- * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
- * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
- * @package cake
- * @subpackage cake.cake.libs.model.datasources
- * @since CakePHP(tm) v 0.10.0.1076
- * @version $Revision: 6311 $
- * @modifiedby $LastChangedBy: phpnut $
- * @lastmodified $Date: 2008-01-02 00:33:52 -0600 (Wed, 02 Jan 2008) $
- * @license http://www.opensource.org/licenses/mit-license.php The MIT License
- */
- uses('set');
- uses('String'); // add this line
- /**
- * DboSource
- *
- * Creates DBO-descendant objects from a given db connection configuration
- *
- * @package cake
- * @subpackage cake.cake.libs.model.datasources
- */
- class DboSource extends DataSource {
I hope this article help you.. ![]()
PHP CLI PROBLEM
January 4th, 2008
Today i’am was learning new web development technology, that is cakePHP web development framework. Yeaahh cake! web development that doesn’t hurt. And i wanna be a professional baker
.
So what’s the relation with cakePHP ? i will not explain what is cakePHP and why use cakePHP. I just want to share my solved problem when working with cakePHP when baking MVC using its console. If your are also a baker, you absolutely know why we are using php command line interface? and you are really same with me if you are using XAMPP for all in one server for web development. Why because i not want to be headcache for doing configuring, compiling, and man other suck tasks. Just unpack the XAMPP package, and you are ready for use it! Your life happy, and you have much time for your girlfriend to get a date with you!
But, unfortunately PHP CLI for the PHP 5 in XAMPP is not compiled in order support with MySQL, and other database extensions. So..? what we must do?
Use php cli for php 4. PHP CLI for php4 is good enough executing all of php application in cakePHP console that had been using pure PHP 5 Object Oriented Programming features.
Find PHP CLI for PHP 4 in xampp\php\php4\phpcli.exe
In order you can use it without any problem happen, you must follow this steps first :
- Set the your windows Environment variable. find in, right click My Computer, and go to Advance tab, and click the Environment Variables butto. Set the Path variable in the System variables group. Add the new value to the existing line with semicolon for separatinhpg new value. Add this value : drive_leter_where_u_save_xampp:\xampp\php\php4 . click Ok, and click Ok again, restart your computer, finish!
- You must use php cli with its important option. The options -c . For more information type phpcli -h in your console
Now you can use php cli for php cli for php 4 and free from suck error message and problem.
Example Use :
I used php cli for php 4 for my web app development with cakePHP console.
phpcli -c \xampp\php\php4\php.ini console\cake bake all
Enjoy..
Generating Excel Report with PHP
December 30th, 2007
INTRO
As a web application developer we often displaying data or displaying report of data from database to our page. Example, sales data, statistical data, and many more as you has done. Now, how if our users want to get data with different format? Maybe users will want to analyze the data in different way. Because, impossible to analyze data in HTML format. It’s easy if we analyze the data in Excel format.
WHAT IS Spreasheet_Excel_Writer
Spreadsheet_Excel_Writer is a set of class from PEAR repository. We can generate Excel document, complete with excel functions and formatting. We can using formula, working in multipl sheet, and much more tasks that often you has done usually with Excel. You can find Spreadsheet_Excel_Writer at PEAR repository site, or if you are using all in one web development package such as XAMPP, there available complete enough classes from PEAR repository, and one from the among is Spreadsheet_Excel_Writer class. You can download the package here ( Spreadsheet_Classess ) after download the package,now you can use Spreadsheet class without depend to PEAR repository structure, you can use the class everywhere.
THE CLASS INFORMATION
The library contains three other classes of which you should be aware, although you may not find yourself having to work with them directly:
- Spreadsheet_Excel_Writer_Validator makes it possible to add cell validation rules. Right now, there’s basically no documentation for this class. It seems to be experimental code, so I’ll be avoiding it here. Basically, it appears to provide the ability to perform basic validation on data entered into an Excel cell by an end user. More complex rules, such as validating against a list of cells, can be implemented by extending the class. The Spreadsheet_Excel_Writer_Workbook class provides the method addValidator() to create an instance of the validation while the Spreadsheet_Excel_Writer_Worksheet allows validators to be assigned to cells with the setValidation() method.
- Spreadsheet_Excel_Writer_Parser, which is a parser for Excel spreadsheet functions that allows you to check whether a function is valid Excel syntax. This may help you trap errors when adding functions to the spreadsheet within PHP.
- Finally, Spreadsheet_Excel_Writer_BIFFwriter is used to generate the Binary File Format for storing Excel files. If you’re interested in Excel hacking, it may be interesting to study what it’s doing but, otherwise, the library hides you from this class completely, so you don’t need to worry about it.
And also another important supporter class that i had to group into one directory.
Let me introduce some basic method that we usually use for generating excel document.
- addWorkSheet()
This method used for creating new worksheet - write()
used for put a data to cell. - writeRow()
used for put data to cell. The different between write() and writeRow() is, write() just render data once into selected cell each we call, and if writeRow(), will render data depend on how many data passed into the writeRow(). The data in writeRow() saved as array() - send()
used for telling browser the type of raw data will come from server - close()
used for erasing class data in memory that we had to instatiate before.
And next, i will explain in more detail only this two important method (because this method is most frequently used) the method is write() and writeRow() method.
write()
what kind of things we passed to this method? first you must imagine we are in front of Excel window now. Illustrated as below :

As you can see above, letter A,B,C,D,etc is named column. And number 1,2,3,etc is named row. It’s funny if i tell you something like this
but, no problem because this will relate with the methods.
In Excel, rows starting from ” 1 ” as u can see above. But in PHP, in the Spreadsheet class, rows is starting from zero. And the starting column is start from zero in Excel, and also in PHP. The letter A equal Zero, B equal 1, C equal 2 and so on..
basic uses of write() method is like this :
$worksheet->write(which_row,which_column,’the data’,cell_style);
which_row : is an integer value that represent the position of row
which_column : is an integer value that represent the position of column
the data : is an string value
cell_style : is a object data type that contain many property of cell style.
example use : $worksheet->write(0,0,’Hello iam in first row and first column’,$xls->addFormat(array(’color’ => ‘red’)));
The above explanation will look like the picture below :

And next, the writeRow() method.
basic uses of writeRow() method is like this :
$worksheet->write(which_row,start_from_which_column,the_data_in_array,cell_style);
which_row : is an integer value that represent the position of row
start_from_which_column : is an integer value that represent the start position of column
the_data_in_array : is an array data type that contain data
cell_style : is a object data type that contain many property of cell style.
example use :
$column = array(’Name’, ‘E-Mail’,'Address’,'Contact Number’);
$worksheet->write(0,0,$column,$xls->addFormat(array(’color’ => ‘red’)));
Do you remember the different of write() and writeRow() method? i hope you remember
. The above explanation is look like this :

Ho ho… i think that’s enough for you to begin to Strike it!
LET’S STRIKE !
As you had to read above, now we will making some basic and simple excel document. Let’s write following code in your favourite editor.
Just for information, my directory structure is like this : C:\xampp\htdocs\Excel\ExcelWriter , ExcelWriter directory contain all of classes.
xls1.php
- <?php
- require_once('ExcelWriter/Writer.php');// class instantiation
- $xls = new Spreadsheet_Excel_writer();// Creating new worksheet
- $worksheet =& $xls->addWorksheet('My First');// defining some data for writeRow() method
- $data = array('Happy','New','Year', '2008');// Putting data into selected row and column
- $worksheet->write(0,0,'Hello iam in first row and first column');
- $worksheet->write(0,1,'Hello iam in first row and 2nd column');
- $worksheet->write(0,2,'Hello iam in first row and 3rd column');
- // keep track the rows if you want to put data in a new row
- $worksheet->writeRow(1,0,$data);
- $xls->send('my_first.xls');
- $xls->close();
- ?>
Just run, and you will get pure xls / Excel document format with data that we have to put with write() method. You must know it, why we call write() method from object variable $worksheet ? and why we call addWorksheet() method from object variable $xls ?
That’s because relate with class structure. object $xls handling all tasks outside of worksheet ( creating new worksheet, setting our worksheet cells,etc) and object $worksheet handling all tasks inside of our worksheet ( putting data to cell, adding formula to cell, changing cells color, etc ) . What object $xls doing is affect globally our worksheet, and $worksheet just handling the internal cells tasks. Woww…
it’s difficult enough to explain, try to understand by yourself
. And, you must remember, we must keep track our rows, if we want to put data in a new row
Ok, now we can to generate very simple excel document
SETTING THE CELL
Now i introduce some common method for setting our cells. With this methods, we can setting height, width, foreground color, text color, and merging the cells.Below is list of the methods that we will use :
- setColumn()
Used for setting the width of a single column or a range of columns.
Basic use : $worksheet->setColumn(whichFirst_column_on_the_range,whichLast_column_on_the_range,width); - setRow()
This method is used to set the height and format for a row.
Basic use :
$worksheet->setRow(which_row,height_for_the_row,row_styles); - setMerge()
Sets a merged cell range.
Basic use : $worksheet->setMerge(whichFirst_row,whichFirst_column,whichLast_row,whichLast_column); - setCustomColor()
Setting custom color from limited alternative from fgcolor properties. With this method we can set the foregroung color of our cells with our favourite color from our favourite color palette. All colors is in RGB Format.
Basic use : $xls->setCustomColor(index,red_value,green_value,blue_value); - addFormat()
Adding format ( cell properties ) to a or range of cell. The cell properties is saved as array()
Basic use :
$worksheet->write(0,0,”TITLE”,$xls->addFormat(array(’align’ => ‘center’,'bold’ => 1,’size’ => 13)));
setCustomColor() method must have a index, and the index is defined by ourself. The value is up to you, and must keep in range of number from 8 up to 64. And must have a call at the top of writing tasks with write() method. Call setCustomColor() method before you call methods for writing because its index will be use in addFormat() method properties.
Let’s try to setting our cell height,width,foreground color, adding format and merging the cells.
- <?php
- require_once('ExcelWriter/Writer.php');
- // class instantiation
- $xls = new Spreadsheet_Excel_writer();
- // Creating new worksheet
- $worksheet =& $xls->addWorksheet('My First');
- // start writing data
- $xls->setCustomColor(11,163,178,204);
- $worksheet->setMerge(0,0,0,3); // Merge the columns
- $worksheet->setColumn(0,3,23); // this column set will affect all columns below the very first column.
- $worksheet->setRow(0,30);
- $worksheet->write(0,0,"TITLE",$xls->addFormat(array('align' => 'center','bold' => 1,'size' => 13,'font-name' => 'Helvetica','color' => 'white','fgcolor' => 11)));
- $xls->send('my_first.xls');
- $xls->close();
- ?>