Kamis, 21 Januari 2010

FPDF Limit File Size and Cause A Blank Error Download

According FPDF Faqs we know that : There is no particular limit of FPDF Output filesize. There are some constraints, however:

- The maximum memory size allocated to PHP scripts is usually 8MB. For very big documents, especially with images, this limit may be reached (the file being built into memory). The parameter is configured in the php.ini file.


- The maximum execution time allocated defaults to 30 seconds. This limit can of course be easily reached. It is configured in php.ini and may be altered dynamically with set_time_limit().

- Browsers generally have a 5 minute time-out. If you send the PDF directly to the browser and reach the limit, it will be lost. It is therefore advised for very big documents to generate them in a file, and to send some data to the browser from time to time (with a call to flush() to force the output). When the document is finished, you can send a redirection to it or create a link.
Remark: even if the browser times out, the script may continue to run on the server.

Dear Friends, I Have a Trouble before, and i want to share that The filesize of  FPDF Output can Cause an Error / Blank Output. Actually my maximum allocated memory was 16 MB in php.ini and size of my FPDF Output was 8 MB. This Output cause Error, So I Change my maximum allocated memory to 64 MB.

If you have change maximum allocated memory, and still not work, we can increase maximum time to run a script, default 30 Second can be changed into 60 Second.


Hope This Help My Dear Friend.

Minggu, 17 Januari 2010

Export MySQL Query to Word with PHP


After You Read Export MySQL Query to excel with PHP, maybe you also want a to Export MySQL Query to Word with PHP. Same as Export MySQL Query to Excel before, We just need to change two words.

We Just need a Connection, a Table that contain MySQL Row and This Great Script with a bit changes..


header("Content-type: application/vnd.ms-excel");

header("Content-disposition: attachment; filename=cetak_excel.xls"); // filename
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");

Change the green highlighted words to be :

header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment; filename=cetak_word.doc"); // filename
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");


Well Done You Can Produce an Word File that Export MySQL Query to word with PHP.

Kamis, 14 Januari 2010

Export MySQL Query to excel with PHP

I still need learn a lot of PHP Programming. A Reporting is Important in Information System. People usually use PDF an Excel in Reporting. Don't be confuse, it was an easy way to produce a report from mysql database with PHP Programming.

A lot of people maybe confuse how to Export MySQL Query to excel with PHP. Because we usually learn query, connection, show data and manipulation data first. A reporting is final step if we do a programming of a system development .

We Just need a Connection, a Table that contain MySQL Row and This Great Script ..


header("Content-type: application/vnd.ms-excel");

header("Content-disposition: attachment; filename=backup_ijasah.xls"); // filename
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");


<?php
1.Connection File
2.The Script above
3. The MySQL Table from A PHP MySQL Query : Example just produce like this :

?>


Just add the Highlighting syntax above at the top line of your coding.. (It Can be Under Include Connection.php line).

After you call your File from Web Browser You Wil Get Like This



Well Done You Can Produce an Excel File that Export MySQL Query to excel with PHP.






Selasa, 12 Januari 2010

Disable Klik Kanan dengan Javascript

Saya Mendapatkan script Disable Klik Kanan dengan Javascript ini dari seorang teman dan belum mencobanya. Dia mengatakan It work like a charm.

Saya belum percaya karena belum mencobanya. Katanya sih ditempatkan diantara tag <head> dan penutup head </head>.


<SCRIPT language=JavaScript>

var message="tulis msg anda disini";
///////////////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")

</SCRIPT>

Silakan Dicoba ya..Saya lemah di JavaScript dan jarang banget menggunakannya.




Update : Ternyata benar benar ampuh nih script. Silakan dicoba ya.. ini contoh filenya, save aja misal test.html. Masalahnya ini untuk di pemrograman sendiri...Untuk di blogger saya tidak tau caranya....Hiks..

hmmm lanjut dulu...
Tus cobain apa klik kanan berhasil dilakukan untuk melakukan copy textnya..Apa bisa dilakukan klik kanan..???


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<SCRIPT language=JavaScript>

var message="tulis msg anda disini";
///////////////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")

</SCRIPT>

</head>

<body>

aaaaaaaaaaaaaa
</body>
</html>

Kamis, 07 Januari 2010

Error Code : 1235 This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'

First i made a Trigger like this..(To make an update of summary numeric field if any insert happen in one table)

DELIMITER $$

CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `update_jum_proposal` AFTER INSERT ON `tb_proposal`
FOR EACH ROW BEGIN
DECLARE NEW_VALUE int;
SELECT count(id) INTO NEW_VALUE FROM tb_proposal where tahun = new.tahun;

update tb_dwh_pengabdian set pengabdian_jum_proposal = NEW_VALUE where pengabdian_tahun=new.tahun;
END;
$$

DELIMITER ;


and then an error occured :
Error Code : 1235
This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'
(0 ms taken)


How this can be solved : Just add an Drop Trigger Statement


DELIMITER $$

DROP TRIGGER /*!50032 IF EXISTS */ `db_pengabdian`.`update_jum_proposal`$$

CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `update_jum_proposal` AFTER INSERT ON `tb_proposal`
FOR EACH ROW BEGIN
DECLARE NEW_VALUE int;
SELECT count(id) INTO NEW_VALUE FROM tb_proposal where tahun = new.tahun;

update tb_dwh_pengabdian set pengabdian_jum_proposal = NEW_VALUE where pengabdian_tahun=new.tahun;
END;
$$

DELIMITER ;



I Found this at http://forums.mysql.com/read.php?99,161909,162074#msg-162074.

Hope this help anyone...

Rabu, 06 Januari 2010

HTML Sticky Form, HTML Form That Remember The Value


HTML Sticky Form, What is that..? HTML Sticky Form is HTML Form That Remember The Value that has been POST or Get after a Submitting.

Have You Ever doing a inputting data in a web information system that has so many field to input.
How about a failure to input the data, I mean a connection failure or our input making a system denied to save the data?? We will a little bit angry to re-enter the data from the beginning.

A PHP Programmer usually know about this technique because very simple. It is very important if we develop a user friendly information system. But usually we are lazy to do that..wait, wait and until the system implementation many protest from the user.

We must prepare about this condition, so if there any time to make the HTML Form become HTML Sticky Form, just do it.

A simple way to make HTML Sticky Form is adding a value in the HTML Element

echo"<input name=\"nama\" type=\"text\" size=\"40\" value=\"$_POST[nama]\" $readonly />";

or more simple HTML Syntax, that using

<input name=nama type=text size=40 value=<?php echo"$_POST[nama]"; > >

Remember the form action, if the action was post use POST in the HTML elemen (form above using post method). You can also use get method, just change
$_POST[nama] with $_GET[nama].


Senin, 04 Januari 2010

Trigger After Delete on MySQL

It quite difficult to hear somebody explain about Trigger or Stored Procedure inDatabase Management System (DBMS). But step by step we learn, we can do it.

In this Simple Post, I'll try to make an easy Trigger After Deleting data on MySQL.

The Process Was a Copying into a table : If Any Row Delete happen in Main Table, Trigger a Copy Row into a Table named like Tbl_Deleted.

Below Was The Trigger.

DELIMITER $

DROP TRIGGER /*!50032 IF EXISTS */ `db_wisuda`.`del_biodata`$$

CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `del_biodata` AFTER DELETE ON `tb_name`
FOR EACH ROW BEGIN
delete from tb_user where username = old.nim;

insert into tb_name_del
(id,
name,
terbaik,
nopenanda
)
values
(old.idbiodata,
old.name,
old.terbaik,
old.nopenanda
);
END;
$$

DELIMITER ;


The Process was simple, If delete happen in tb_name, delete the users in tb_user and copy the data that has been deleted to tb_name_del.

Old mean the table that has been delete.
You can see username=old.nim

i have the tb_user that the tb_user username = tb_name.nim