<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>夢の翼 &#187; php</title>
	<atom:link href="http://neo.rizkhey.net/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://neo.rizkhey.net</link>
	<description>~ Wings of Dream ~</description>
	<lastBuildDate>Wed, 08 Feb 2012 14:57:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Fixing Select Limit Issue for Microsoft SQL Server Driver in Codeigniter</title>
		<link>http://neo.rizkhey.net/2012/01/4136-fixing-select-limit-issue-for-microsoft-sql-server-driver-in-codeigniter</link>
		<comments>http://neo.rizkhey.net/2012/01/4136-fixing-select-limit-issue-for-microsoft-sql-server-driver-in-codeigniter#comments</comments>
		<pubDate>Fri, 13 Jan 2012 10:33:34 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sqlsrv]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=4136</guid>
		<description><![CDATA[Driver untuk mengakses Microsoft SQL server telah disediakan oleh framework CodeIgniter semenjak saya mencoba framework ini pertama kali (versi 1.6 kalau tak salah) sekitar 1-2 tahun lalu. Walau begitu saat itu untuk fungsi emulasi LIMIT yang dibutuhkan untuk pagination tidak berjalan seperti seharusnya. Bahkan sampai sekarang, versi 2.1.0 tetap demikian. Setelah perjalanan lama ini, akhirnya saya menemukan modifikasi cukup ampuh agar pagination dengan database Microsoft SQL server dapat berjalan baik di CodeIgniter.]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Sekitar tahun 2008 saya mulai melihat framework-framework yang umum dan disebar di Internet saat itu. Salah satunya yang cukup terkenal saat itu(hingga sekarang) adalah CodeIgniter. Pada saat itu saya membutuhkan sebuah framework untuk membuat proyek yang menggunakan Microsoft SQL Server(<em>As requested from my client</em>). Karena dalam PHP saya kurang perpengalaman menggunakan MS SQL sebagai DBMS-nya, akhirnya saya mencoba CI untuk calon framework yang saya akan gunakan.</p>
<p><span id="more-4136"></span></p>
<p style="text-align: justify;">Sayangnya hal itu kandas karena pada saat itu driver untuk MS SQL server yang disediakan oleh CI terutama dalam hal limit-nya bisa dibilang cacat. Walau metodologi yang digunakan sama dengan yang digunakan oleh ADODB(saya pernah bahas di artikel : <a title="Emulate Microsoft SQL Server Select Limit(2005 and above)" href="http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above">Emulate Microsoft SQL Server Select Limit(2005 and above)</a>), sayangnya apabila ADODB masih memilah lagi resultnya supaya yang dikembalikan seperti yang diminta user, sedangkan CI mengembalikannya mentah-mentah.</p>
<blockquote><p style="text-align: justify;">Sebelum melaju lebih jauh, syarat mutlak yang dibutuhkan adalah Anda sudah menggunakan Microsoft SQL Server 2005 atau lebih tinggi, karena cara ini tidak berjalan pada Database Ms. SQL Server 2000, dan driver PHP ke Ms. SQL Server baik mssql atau sqlsrv telah terinstall pada server Anda</p>
</blockquote>
<p style="text-align: justify;">Untuk lebih memahami, cobalah membuat sebuah table dengan nama &#8220;strong>tutorial_limit</strong>&#8221; di database MSSQL Anda dengan meng-execute SQL berikut ini.<br />
[sql]<br />
CREATE TABLE [dbo].[tutorial_limit](<br />
	[id] [int] IDENTITY(1,1) NOT NULL,<br />
	[name] [varchar](200) NOT NULL,<br />
	[some_random] [varchar](255) NOT NULL,<br />
 CONSTRAINT [PK_tutorial_limit] PRIMARY KEY CLUSTERED<br />
(<br />
	[id] ASC<br />
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]<br />
) ON [PRIMARY]<br />
[/sql]</p>
<p style="text-align: justify;">Lalu set koneksi database Anda ke Database MS SQL Anda menggunakan driver mssql/sqlsrv. Sebagai contoh, config yang saya gunakan adalah sbb:</p>
<p>[php num="51"]<br />
$db['default']['hostname'] = &#8216;.&#8217;;<br />
$db['default']['username'] = &#8216;sa&#8217;;<br />
$db['default']['password'] = &#8216;sa&#8217;;<br />
$db['default']['database'] = &#8216;tutorial&#8217;;<br />
$db['default']['dbdriver'] = &#8216;sqlsrv&#8217;;<br />
$db['default']['dbprefix'] = &#8221;;<br />
$db['default']['pconnect'] = TRUE;<br />
$db['default']['db_debug'] = TRUE;<br />
$db['default']['cache_on'] = FALSE;<br />
$db['default']['cachedir'] = &#8221;;<br />
$db['default']['char_set'] = &#8216;utf8&#8242;;<br />
$db['default']['dbcollat'] = &#8216;utf8_general_ci&#8217;;<br />
$db['default']['swap_pre'] = &#8221;;<br />
$db['default']['autoinit'] = TRUE;<br />
$db['default']['stricton'] = FALSE;<br />
[/php]</p>
<p style="text-align: justify;">Saya menggunakan extension <a title="SQLSRV, native Microsoft SQL Server Extension for PHP" href="http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php">Ms. SQL Server Native(sqlsrv)</a> karena XAMPP yang saya gunakan Apachenya sudah menggunakan compile-an dari VC9 begitu juga dengan PHP-nya(mssql extension dll yang saya punya hanya untuk VC6 <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /> )</p>
<p>Kemudian buatlah sebuah file controller dengan nama &#8220;<strong>paging_example.php</strong>&#8221; isilah dengan code berikut ini:<br />
[php]<br />
<?php<br />
/**<br />
* @property CI_Form_validation $form_validation<br />
* @property CI_Input $input<br />
* @property CI_DB_active_record $db<br />
* @property CI_DB_forge $dbforge<br />
* @property CI_Session $session<br />
* @property CI_Loader $load<br />
* @property CI_Upload $upload<br />
*/</p>
<p>class Paging_example extends CI_Controller<br />
{</p>
<p>    function  __construct() {<br />
        parent::__construct();<br />
        $this->load->database();<br />
        $this->load->library(array(&#8216;table&#8217;,'pagination&#8217;));<br />
    }</p>
<p>    function insert_dummy()<br />
    {<br />
            for ( $i = 0 ; $i < 300 ; $i++ )<br />
            {<br />
                    $data_insert = array(<br />
                            'name' => &#8216;this is row &#8216; . ($i+1),<br />
                            &#8216;some_random&#8217; => sha1($i)<br />
                    );</p>
<p>                    $this->db->insert(&#8216;tutorial_limit&#8217;,$data_insert);<br />
            }<br />
    }</p>
<p>    function some_paging()<br />
    {<br />
        /* set base config of pagination */<br />
        $config['base_url'] = base_url() . &#8216;paging_example/some_paging&#8217;;<br />
        $config['total_rows'] = $this->db->count_all_results(&#8216;tutorial_limit&#8217;);<br />
        $config['per_page'] = 10;</p>
<p>        $this->pagination->initialize($config);</p>
<p>        $data['records'] = $this->db->get(&#8216;tutorial_limit&#8217;, $config['per_page'], $this->uri->segment(3));<br />
        $data['link_pagination'] = $this->pagination->create_links();<br />
        $this->load->view(&#8216;pagination&#8217;,$data);<br />
    }<br />
}</p>
<p>?><br />
[/php]</p>
<p>Kita sekalian buat untuk view-nya, kita buat sebuah file dengan nama &#8220;<strong>pagination.php</strong>&#8221; isilah dengan code berikut ini:</p>
<p>[html]<br />
<html><br />
    <head></p>
<p>    </head><br />
    <body><br />
        <?php if ( $records->num_rows() > 0 ){ ?><br />
            <?php echo $this->table->generate($records); ?><br />
        <?php } ?><br />
        <?php echo $link_pagination; ?><br />
    </body><br />
</html><br />
[/html]</p>
<p style="text-align: justify;">Perhatikan kode controller di atas, kita akan membuat dua page, yaitu &#8220;insert_dummy&#8221; dan juga &#8220;some_paging&#8221;. untuk melakukan tutorial ini, kita membutuhkan data-data dummy untuk pagination, maka dari itu kita akan coba insert dummy data secara otomatis sebanyak 300 row.</p>
<p style="text-align: justify;">Execute-lah page &#8220;insert_dummy&#8221; tersebut(arahkan browser ke <strong>http://[your_host]/[path_to_ci_directory]/index.php/paging_example/insert_dummy</strong>), sehingga apabila anda lihat, table yang Anda buat sudah berisi 300 row.</p>
<div id="attachment_4142" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/sql_dummy_data.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/sql_dummy_data-450x428.jpg" alt="Dummy Data sebanyak 300 row" title="Dummy Data sebanyak 300 row" width="450" height="428" class="size-medium wp-image-4142" /></a><p class="wp-caption-text">Dummy Data sebanyak 300 row</p></div>
<p style="text-align: justify;">Kemudian cobalah jalankan page &#8220;some_paging&#8221; (arahkan browser ke <strong>http://[your_host]/[path_to_ci_directory]/index.php/paging_example/some_paging</strong>) </p>
<div id="attachment_4144" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/paging_1st_page.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/paging_1st_page-450x258.jpg" alt="1st Page of Pagination" title="1st Page of Pagination" width="450" height="258" class="size-medium wp-image-4144" /></a><p class="wp-caption-text">Saat halaman &quot;some_paging&quot; dijalankan akan muncul seperti ini kurang lebih</p></div>
<p style="text-align: justify;">Tidak nampak sesuatu yang aneh? tentu saja ini baru halaman utama. Apabila Anda melihat/membuka SQL-server Profiler, Anda akan melihat query yang di execute adalah:</p>
<p>[sql]SELECT TOP 10 * FROM tutorial_limit[/sql]</p>
<p style="text-align: justify;">Ok&#8230; mari kita klik halaman kedua  <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> </p>
<div id="attachment_4146" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/2nd_page.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/2nd_page-450x427.jpg" alt="2nd page" title="2nd page" width="450" height="427" class="size-medium wp-image-4146" /></a><p class="wp-caption-text">Kekacuan muncul mulai page kedua dimana hasil yang tidampilkan sebanyak 20 row padahal seharusnya yang di kembalikan hanya 10 row data saja</p></div>
<p style="text-align: justify;">SQL yang kita lihat mungkin akan seperti ini:</p>
<p>[sql]SELECT TOP 20 * FROM tutorial_limit[/sql]</p>
<p style="text-align: justify;">Lanjuut&#8230;. ke 3rd page <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> </p>
<div id="attachment_4145" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/3rd_page.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/3rd_page-450x427.jpg" alt="3rd page" title="3rd page" width="450" height="427" class="size-medium wp-image-4145" /></a><p class="wp-caption-text">Kekacuan terus berlanjut, untuk halaman ketiga mengembalikan 30 row <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p></div>
<p style="text-align: justify;">Lanjutnya sudah pasti akan menjadi seperti ini:</p>
<p>[sql]SELECT TOP 30 * FROM tutorial_limit[/sql]</p>
<p style="text-align: justify;">Dengan kata lain semakin ke belakang jumlah record yang ditampilkan akan berjumlah </p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[jumlah record per page] * [current page]</div></div>
<h4>Penyelesaian</h4>
<p style="text-align: justify;">Untuk menyelesaikan masalah ini, kita bisa membuka file di dalam folder </p>
<p>Untuk yang menggunakan <strong><em>mssql</em></strong> extension</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">system/database/drivers/mssql/mmsql_driver.php</div></div>
<p>Untuk yang menggunakan <strong><em>sqlsrv</em></strong> extension</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">system/database/drivers/sqlsrv/sqlsrv_driver.php</div></div>
<p style="text-align: justify;">Carilah method &#8220;<em>_limit</em>&#8221; di file yang Anda buka(di kedua driver baik sqlsrv atau mssql berisi kode yang sama persis):</p>
<p>[php]<br />
/**<br />
	 * Limit string<br />
	 *<br />
	 * Generates a platform-specific LIMIT clause<br />
	 *<br />
	 * @access	public<br />
	 * @param	string	the sql query string<br />
	 * @param	integer	the number of rows to limit the query to<br />
	 * @param	integer	the offset value<br />
	 * @return	string<br />
	 */<br />
	function _limit($sql, $limit, $offset)<br />
	{<br />
		$i = $limit + $offset;</p>
<p>		return preg_replace(&#8216;/(^\SELECT (DISTINCT)?)/i&#8217;,'\\1 TOP &#8216;.$i.&#8217; &#8216;, $sql);<br />
	}<br />
[/php]</p>
<p style="text-align: justify;">Saya pernah membahas sebelumnya bagaimana melimit hasil query Microsoft SQL Server di level database dan bukan di level PHP (<a href="http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above" title="Emulate Microsoft SQL Server Select Limit(2005 and above)">disini</a>), dalam kasus ini saya akan menggunakan kode serupa agar fungsi limit untuk driver Microsoft SQL server di CI ini(baik menggunakan <em>mssql </em>ataupun <em>sqlsrv</em>) dapat berjalan seperti seharusnya. Caranya replace seluruh isi method &#8220;<em>__limit</em>&#8221; menjadi seperti snippet berikut ini:</p>
<p>[php]<br />
    /**<br />
	 * Limit string<br />
	 *<br />
	 * Generates a platform-specific LIMIT clause<br />
	 *<br />
	 * @access	public<br />
	 * @param	string	the sql query string<br />
	 * @param	integer	the number of rows to limit the query to<br />
	 * @param	integer	the offset value<br />
	 * @return	string<br />
	 */<br />
	function _limit($sql, $limit, $offset)<br />
	{</p>
<p>		$sql = str_replace(&#8220;\n&#8221;, &#8221; &#8220;, $sql);</p>
<p>		$orderby = stristr($sql, &#8216;ORDER BY&#8217;);</p>
<p>		if (!$orderby)<br />
		{<br />
			$over = &#8216;ORDER BY (SELECT 0)&#8217;;<br />
		}<br />
		else<br />
		{<br />
			$over = preg_replace(&#8216;/\&#8221;[^,]*\&#8221;.\&#8221;([^,]*)\&#8221;/i&#8217;, &#8216;&#8221;inner_tbl&#8221;.&#8221;$1&#8243;&#8216;, $orderby);<br />
		}</p>
<p>		// Remove ORDER BY clause from $sql<br />
		$sql = preg_replace(&#8216;/\s+ORDER BY(.*)/&#8217;, &#8221;, $sql);</p>
<p>		// Add ORDER BY clause as an argument for ROW_NUMBER()<br />
		$sql = &#8220;SELECT ROW_NUMBER() OVER ($over) AS \&#8221;ZEND_DB_ROWNUM\&#8221;, * FROM ($sql) AS inner_tbl&#8221;;</p>
<p>		$start = $offset + 1;<br />
		$end = $offset + $limit;</p>
<p>		$sql = &#8220;WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE ZEND_DB_ROWNUM BETWEEN $start AND $end&#8221;;</p>
<p>		return $sql;<br />
	}<br />
[/php] </p>
<blockquote><p style="text-align: justify;">Setelah diubah save file driver tersebut. Apabila Anda menggunakan extension &#8220;<em>sqlsrv</em>&#8221; ada sedikit masalah yang harus dihadapi lagi, apabila Anda merefresh halaman pagination, maka Anda tidak akan menampilkan satu row datapun, tetapi pagination berjalan tanpa ada error/warning. </p>
<p style="text-align: justify;">Hal ini diakibatkan karena masih ada Bug pada driver library SQLSRV dari Microsoft(sampai yang saat ini saya gunakan versi 2.0) dimana pada query yang complex, fungsi yang digunakan untuk me-<em>return</em> jumlah row(<em><strong>sqlsrv_num_rows</strong></em>) akan mereturn nilai &#8220;-1&#8243; dan bukan jumlah row yang dikembalikan. Sehingga otomatis tidak mengembalikan apapun. Untuk mengatasinya, Anda bisa mengedit file &#8220;<strong>system\database\drivers\sqlsrv\sqlsrv_result.php</strong>&#8221; carilah method &#8220;<strong>num_rows</strong>&#8220;. Ubah kode dari:</p>
<p>[php]<br />
    function num_rows()<br />
	{<br />
		return @sqlsrv_num_rows($this->result_id);<br />
	}<br />
[/php]<br />
menjadi:<br />
[php]<br />
    function num_rows()<br />
	{<br />
		$num_row = @sqlsrv_num_rows($this->result_id);<br />
		if ( $num_row == -1 ){ return 1; }<br />
                else { return $num_row; }</p>
<p>	}<br />
[/php]</p>
<p style="text-align: justify;">Sekarang apabila Anda save dan coba refresh, seharusnya sudah normal. Ini dikarenakan dalam class html table akan mengecek apakah object hasil query yang diberikan memiliki result > 0 atau tidak. Secara koding akan seperti ini:</p>
<p>[php]<br />
if ( $query->num_rows() > 0 ){<br />
 //do something like printing row data/etc<br />
}<br />
[/php]</p>
<p style="text-align: justify;">Tetapi karena hasil dari method &#8220;num_rows()&#8221; adalah -1 sehingga kondisi tidak terpenuhi maka PHP tidak menulis apapun. Mod diatas digunakan untuk mengakali, apabila yang direturn(oleh sqlsrv library dalam PHP) adalah -1, maka dari si driver(dalam CI db driver) akan mereturn nilai 1 sehingga kondisi terpenuhi dan <em>loop </em>untuk menulis hasil row akan berjalan.</p>
<p style="text-align: justify;">Hal ini akan selalu terjadi apabila Anda menggunakan perintah <strong>limit</strong> di Active record class. Apabila Anda ingin mengetahui jumlah row yang dihasilkan secara pasti, saya biasa mengakali dengan perintah dasar &#8220;<strong>count</strong>&#8221; dalam PHP.</p>
<p>[php]<br />
$real_num_row = count($query->result_array());<br />
[/php]
</p></blockquote>
<p>Okay.. let&#8217;s roll&#8230; kita lihat hasilnya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div id="attachment_4162" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/1st_fix.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/1st_fix-450x295.jpg" alt="1st page FIX" title="1st page FIX" width="450" height="295" class="size-medium wp-image-4162" /></a><p class="wp-caption-text">1st page FIX (yay... tentu saja, sejak semula masalah tidak timbul di halaman pertama <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> )</p></div>
<p>Lanjut ke halaman kedua yang mana sebelum kita modifikasi jumlah row yang muncul berjumlah 10&#8230; dan hasilnya&#8230;.</p>
<div id="attachment_4163" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/2nd_fix.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/2nd_fix-450x295.jpg" alt="2nd Page Fix" title="2nd Page Fix" width="450" height="295" class="size-medium wp-image-4163" /></a><p class="wp-caption-text">Yeah, Halaman kedua masalah selesai... tidak ada lagi 20 row yang muncul</p></div>
<p>Ok fix&#8230; mari kita langsung lompat ke halaman yang agak jauh, dan hasilnya&#8230;.</p>
<div id="attachment_4161" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/fix.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/fix-450x304.jpg" alt="Page 28, FIX!!" title="Page 28, FIX!!" width="450" height="304" class="size-medium wp-image-4161" /></a><p class="wp-caption-text">Yes, we have no problem now <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p></div>
<p>Apabila Anda perhatikan, dalam setiap list akan menambahkan satu kolom bernama &#8216;ZEND_DB_ROWNUM&#8217;. Anda dapat sembunyikan kolom tersebut secara manual.</p>
<p>Thankyou <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> </p>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=4136&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2012/01/4136-fixing-select-limit-issue-for-microsoft-sql-server-driver-in-codeigniter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emulate Microsoft SQL Server Select Limit(2005 and above)</title>
		<link>http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above</link>
		<comments>http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above#comments</comments>
		<pubDate>Thu, 12 Jan 2012 03:17:10 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[Microsoft SQL Server]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=4100</guid>
		<description><![CDATA[SQL server adalah salah satu DBMS yang cukup favorit(Selain MySQL yang free atau Oracle yang memang sudah jadi pentolnya DBMS). Beberapa kali saya menggunakan SQL server sebagai DBMS project saya. Karena saya menggunakan PHP sebagai main programing language, agak sulit awalnya saat saya mencari cara untuk melakukan pagination dengan menggunakan SQL server.
Latar belakang kenapa saya [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">SQL server adalah salah satu DBMS yang cukup favorit(Selain MySQL yang free atau Oracle yang memang sudah jadi pentolnya DBMS). Beberapa kali saya menggunakan SQL server sebagai DBMS project saya. Karena saya menggunakan PHP sebagai main programing language, agak sulit awalnya saat saya mencari cara untuk melakukan pagination dengan menggunakan SQL server.</p>
<p style="text-align: justify;">Latar belakang kenapa saya menulis post ini adalah:</p>
<p><span id="more-4100"></span></p>
<blockquote style="text-align: justify;"><p>Seperti yang kita tahu seperti MySQL atau Postgre SQL memiliki fungsi LIMIT(Yang katanya bukan merupakan standart SQL internasional) dan sangat mudah untuk melimit hasil query, tetapi tidak untuk MSSQL server.</p>
<p>Saya  masih ingat dulu akhirnya saya bermain dengan XML data source dengan menggunakan Adobe Spry dataset untuk melakukan paging, hanya saja pastinya karena diload semua, apabila data sudah amat banyak bukan main lamanya.</p>
<p>Setelah beberapa lama akhirnya saya menggunakan Database Abstraction Layer dengan menggunakan <a title="ADODB for PHP" href="http://adodb.sourceforge.net/" target="_blank">ADODB</a> untuk PHP. library yang besar ini mempunyai virtualisasi untuk LIMIT function. Tetapi apabila kita tinjau lebih dalam virtualisasi Limit, yang disediakan ternyata hanya akan membantu sesaat. Kenapa demikian?</p>
<p>Banyak yang mengakali fungsi limit untuk SQL server di PHP menggunakan perintah TOP di SQL querynya, kemudian return data ke pengakses berdasarkan logic di PHP. Dengan kata lain semakin besar offsetnya, akan semakin besar overhead yang terjadi. Sebagai contoh mungkin apabila kita mau melihat 40 record pertama, library ADODB akan membuat syntax </p>
<p>[sql]SELECT TOP 40 * FROM some_table[/sql]</p>
<p>Karena kasusnya adalah 40 row pertama sehingga akan langsung dikembalikan semuanya. Tetapi apabila kita hendak melihat 40 row kedua(di halaman/pahge kedua misalnya), maka library ADODB  akan membuat query:<br />
[sql]SELECT TOP 80 * FROM some_table[/sql]<br />
Lalu hasilnya akan me-<em>return</em> 80 row data, kemudian diseleksi lagi untuk row 0-39 akan diabaikan, dan row 40-79 akan di return. </p>
<p>Okay&#8230; itu masih <em>acceptable  </em>karena isinya hanya under 100 row&#8230; bahkan 1000 row masih bisa dibilang tidak begitu pengaruh&#8230; lalu apabila yang kita hendak lakukan pagination adalah 200.000 row? maka apabila kita ingin melihat halaman terakhir, maka ke 200.000 row akan di retrieve oleh PHP dan hanya diambil 40 row terakhir saja. Inilah yang membuat overhead.</p>
</blockquote>
<p><!--more--></p>
<p style="text-align: justify;">Saya  masih ingat dulu untuk melakukan Limitasi Select data, Query harus dirubah cukup panjang. Pastinya tidak bisa dibilang query standard lagi dan tidak bisa diterapkan secara mudah dengan banyak query yang sudah ada(aka harus dibongkar query-nya). Tentunya bukan sesuatu yang enak di dengar oleh telinga Developer <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> . Setelah kemarin saya iseng memulai belajar Zend Framework mata saya tertuju di salah satu library <a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> yaitu &#8220;db&#8221; yang di dalamnya sudah terdapat adapter untuk extensi &#8220;<em><a href="http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php" title="SQLSRV, native Microsoft SQL Server Extension for PHP">sqlsrv</a></em>&#8221; Dan setelah dibaca sedikit demi sedikit saya mengambil satu bagian yang menarik yang tugasnya untuk melakukan LIMIT(Little modified <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> ).</p>
<p>[php]<br />
/**<br />
* Adds an adapter-specific LIMIT clause to the SELECT statement.<br />
*<br />
* @param string $sql<br />
* @param integer $count<br />
* @param integer $offset OPTIONAL<br />
* @return string<br />
* @throws Zend_Db_Adapter_Sqlsrv_Exception<br />
*/<br />
function limit($sql, $count, $offset = 0)<br />
{<br />
	$orderby = stristr($sql, &#8216;ORDER BY&#8217;);</p>
<p>	if (!$orderby) {<br />
		$over = &#8216;ORDER BY (SELECT 0)&#8217;;<br />
	} else {<br />
		$over = preg_replace(&#8216;/\&#8221;[^,]*\&#8221;.\&#8221;([^,]*)\&#8221;/i&#8217;, &#8216;&#8221;inner_tbl&#8221;.&#8221;$1&#8243;&#8216;, $orderby);<br />
	}</p>
<p>	// Remove ORDER BY clause from $sql<br />
	$sql = preg_replace(&#8216;/\s+ORDER BY(.*)/&#8217;, &#8221;, $sql);</p>
<p>	// Add ORDER BY clause as an argument for ROW_NUMBER()<br />
	$sql = &#8220;SELECT ROW_NUMBER() OVER ($over) AS \&#8221;ZEND_DB_ROWNUM\&#8221;, * FROM ($sql) AS inner_tbl&#8221;;</p>
<p>	$start = $offset + 1;<br />
	$end = $offset + $count;</p>
<p>	$sql = &#8220;WITH outer_tbl AS ($sql) SELECT * FROM outer_tbl WHERE CAST(ZEND_DB_ROWNUM as bigint ) BETWEEN $start AND $end&#8221;;</p>
<p>	return $sql;<br />
}<br />
[/php]</p>
<p style="text-align: justify;">Fungsi diatas manambahkan SQL query menjadi agak panjang, tetapi paling tidak sudah dibantu pembuatnnya tinggal dibungkus dalam class Database Abstraction layer milik Anda atau digunakan ala kadarnya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: justify;">Contoh pemakaian(apabila menggunakan <strong><em><a href="http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php" title="SQLSRV, native Microsoft SQL Server Extension for PHP">sqlsrv </a></em></strong>extension, kurang lebih sama dengan <strong><em>mssql</em></strong> function biasa):</p>
<p>[php]<br />
$conn = sqlsrv_connect( &#8220;SERVERADDRS/IPADDRESS&#8221;, array(&#8220;UID&#8221; => &#8216;sqlserv_userid&#8217;, &#8220;PWD&#8221; => &#8216;sqlserv_password&#8217;, &#8220;Database&#8221;=>&#8221;dbname&#8221;));<br />
if( $conn === false )<br />
{<br />
	echo &#8220;Could not connect.\n&#8221;;<br />
	die( print_r( sqlsrv_errors(), true));<br />
}</p>
<p>$str = &#8220;SELECT * FROM TBObject WHERE 1=1 ORDER BY Name &#8220;;</p>
<p>//fetch data from record 11 of 20 record<br />
$stmt = sqlsrv_query( $conn, limit($str,20,11), array(), array( &#8220;Scrollable&#8221; => SQLSRV_CURSOR_KEYSET ));<br />
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_BOTH))<br />
{<br />
	var_dump($row);<br />
}<br />
[/php]</p>
<p>Contoh dengan <strong><em>mssql</em></strong> Function:<br />
[php]<br />
mssql_connect(&#8217;10.0.0.23&#8242;, &#8216;sa&#8217;, &#8216;xxxx&#8217;);<br />
mssql_select_db(&#8216;dbname&#8217;);</p>
<p>$str = &#8220;SELECT * FROM TBObject WHERE 1=1 ORDER BY Name &#8220;;</p>
<p>$result = mssql_query(limit($str, 20,11));</p>
<p>while($r = mssql_fetch_array($result))<br />
{<br />
	var_dump($r);<br />
}<br />
[/php]</p>
<p style="text-align: justify;">Fungsi diatas akan mengubah Query seperti:</p>
<p>[sql]SELECT * FROM TBObject WHERE 1=1 ORDER BY Name[/sql]</p>
<p style="text-align: justify;">Fungsi diatas akan mengubah Query seperti:</p>
<p>[sql]WITH outer_tbl AS (SELECT ROW_NUMBER() OVER (ORDER BY Name ) AS &#8220;ZEND_DB_ROWNUM&#8221;, * FROM (SELECT * FROM TBObject WHERE 1=1) AS inner_tbl) SELECT * FROM outer_tbl WHERE CAST(ZEND_DB_ROWNUM as bigint ) BETWEEN 12 AND 31[/sql]</p>
<p style="text-align: justify;">Good Luck <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<blockquote><p>Artikel ini sebenarnya pernah saya tulis, hanya tak sengaja terhapus saat error pada server terjadi beberapa waktu lalu, sehingga saya rewrite ulang dengan draft yang pernah saya buat <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> </p></blockquote>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=4100&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interactive Drag&amp;Drop Sorting with jQueryUI &amp; AJAX</title>
		<link>http://neo.rizkhey.net/2012/01/4066-interactive-dragdrop-sorting-with-jqueryui-ajax</link>
		<comments>http://neo.rizkhey.net/2012/01/4066-interactive-dragdrop-sorting-with-jqueryui-ajax#comments</comments>
		<pubDate>Mon, 09 Jan 2012 10:59:15 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[mySQl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sortable]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=4066</guid>
		<description><![CDATA[
Dalam sebuah apliaksi web based baik itu intranet ataupun internet/public sering kali user dihadapkan pada sebuah event dimana user harus mengurutkan beberapa item secara manual. Tentu saja apabila kita ingin melakukan secara manual, kita bisa meminta user untuk melakukan input angka sebagai Order Number, apabila kita ingin. Tetapi alangkah lebih baiknya jika kita sedikit &#8216;memanjakan&#8216; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/ilust-e1326106852927-450x382.gif" alt="" title="ilust" width="450" height="382" class="aligncenter size-medium wp-image-4067" /></p>
<p style="text-align: justify;">Dalam sebuah apliaksi web based baik itu intranet ataupun internet/public sering kali user dihadapkan pada sebuah event dimana user harus mengurutkan beberapa item secara manual. Tentu saja apabila kita ingin melakukan secara manual, kita bisa meminta user untuk melakukan input angka sebagai <em>Order Number</em>, apabila kita ingin. Tetapi alangkah lebih baiknya jika kita sedikit &#8216;<em>memanjakan</em>&#8216; user dengan user interface yang lebih <em>interactive</em>, yaitu dengan drag and drop <em>interface</em>.</p>
<p style="text-align: justify;">Dalam tutorial kali ini, target kita adalah membuat sebuah program sederhana terbuat dengan menggunakan PHP dan MYSQL yang akan menampilkan list nama -nama orang yang dapat di sorting dengan menggunakan drag and drop dan saat di drop itemnya, otomatis data di server akan langsung terupdate secara live dengan AJAX menggunakan bantuan dari jQuery UI. Untuk itu, kita membutuhkan beberapa hal yang kita butuhkan, yaitu:</p>
<ol>
<li>Web server untuk PHP &amp; Mysql (Saya mencotohkan dengan menggunakan XAMPP)*</li>
<li>jQuery UI</li>
<li>Text editor untuk programing(bisa menggunakan notepad++, netbeans for PHP, dreamweaver atau sesuai selera)</li>
</ol>
<blockquote>
<pre style="text-align: justify;">*Untuk web server saya anggap sudah dapat menginstallnya</pre>
</blockquote>
<p style="text-align: justify;">Untuk mendownload jQuery UI, bisa langsung mengunjungi halaman download-nya di alamat <a href="http://jqueryui.com/download">http://jqueryui.com/download</a> Sebelum mendownloadnya, boleh sedikit saya terangkan terlebih dahulu mengenai jQueryUI ini.</p>
<p style="text-align: justify;">jQuery UI ini adalah kumpulan-kumpulan modul-modul yang digunakan untuk membuat widget, web web object, animasi, yang sering digunakan secara umum dalam sebuah website, seperti date picker, Accordition, etc . jQuery UI sendiri dapat di download sesuai kebutuhan, misalnya kita akan menggunakan modul &#8220;<em>sortable</em>&#8220;, maka kita hanya butuh mendownload/memilih modul &#8216;<em>sortable</em>&#8216;. Dengan catatan bahwa sebuah modul biasanya memerlukan modul lainnya untuk dapat bekerja. Sebagai contoh untuk tutorial ini, modul &#8216;<em>sortable</em>&#8216; membutuhkan 3 modul lainnya yaitu &#8220;<em>UI core</em>&#8220;,&#8221;<em>UI Widget</em>&#8220;,&#8221;<em>UI Mouse</em>&#8221; untuk dapat bekerja.</p>
<p><span id="more-4066"></span></p>
<div id="attachment_4068" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/depend.jpg"><img class="size-medium wp-image-4068" title="Dependencies" src="http://neo.rizkhey.net/wp-content/uploads/2012/01/depend-450x208.jpg" alt="Dependencies" width="450" height="208" /></a><p class="wp-caption-text">Perhatikan ketergantungan/Dependencies dari sebuah modul yang akan kita gunakan</p></div>
<p style="text-align: justify;">Sehingga minimal untuk menjalakan modul yang akan kita pakai, kita membutuhkan ke-4 modul yang saya sebutkan sebelumnya, checklist-lah ke-4 item di halaman download jQuery UI kemudian klik tombol download(Untuk themes, saya akan menggunakan CSS sederhana untuk <em>styling</em>-nya, sehingga kita tidak akan menggunakan themes bawaan dari jQuery UI).</p>
<div id="attachment_4070" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/downloading_package.jpg"><img class="size-medium wp-image-4070" title="downloading package" src="http://neo.rizkhey.net/wp-content/uploads/2012/01/downloading_package-450x258.jpg" alt="downloading package" width="450" height="258" /></a><p class="wp-caption-text">Downloading package untuk modul sortable yang akan kita pakai</p></div>
<p style="text-align: justify;">Setelah mendownload-nya, extractlah folder &#8220;<em>js</em>&#8221;  yang ada di dalamnya ke sebuah folder dalam folder htdocs local server Anda. Misalnya folder tersebut saya beri nama &#8216;<em>jquery_ui</em>&#8216;, sebelum melanjut lebih jauh, buatlah sebuah table di database Anda dengan menggunakan drop SQL berikut ini:</p>
<p>[sql]<br />
CREATE TABLE IF NOT EXISTS `jqueryui_sort` (<br />
`id` int(11) NOT NULL AUTO_INCREMENT,<br />
`name` varchar(255) NOT NULL,<br />
`order` int(11) NOT NULL,<br />
PRIMARY KEY (`id`)<br />
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;</p>
<p>INSERT INTO `jqueryui_sort` (`id`, `name`, `order`) VALUES<br />
(1, &#8216;Sigit &#8216;, 8),<br />
(2, &#8216;Karto &#8216;, 9),<br />
(3, &#8216;George &#8216;, 4),<br />
(4, &#8216;Joe &#8216;, 6),<br />
(5, &#8216;Ciptanti &#8216;, 1),<br />
(6, &#8216;Nancy &#8216;, 7),<br />
(7, &#8216;Alfonsus &#8216;, 2),<br />
(8, &#8216;Johanna &#8216;, 5),<br />
(9, &#8216;Jaclyn&#8217;, 3);<br />
[/sql]</p>
<h4 style="padding-top:20px;"><strong>Membuat front page interface</strong></h4>
<p style="text-align: justify;">Untuk file front interface buatlah sebuah file, sebagai contoh saya beri nama &#8220;sort.php&#8221; dengan isi sbb:</p>
<p>[php]<br />
<?php<br />
/* connect to mysql databse */<br />
mysql_connect('localhost', 'root', $password);<br />
/* select the database */<br />
mysql_select_db('tutorial');</p>
<p>/* do some query selecting id and names order by ORDER asc */<br />
$str_query = "SELECT id,`name` FROM jqueryui_sort ORDER BY `order` ASC";<br />
$query = mysql_query($str_query)or die(mysql_error());</p>
<p>?><br />
<!DOCTYPE html><br />
<html><br />
    <head><br />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></p>
<p>        <!-- Jquery.js include --><br />
        <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script></p>
<p>        <!-- JqueryUI library include --><br />
        <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script></p>
<style>
            .handler{
                border: solid 1px #2b81af;
                padding: 5px;
                margin: 2px 0px 0px 2px;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
                border-radius: 5px;
                background-color: #fff;
                cursor: pointer;
            }
	</style>
<p>	<script>
            $(function() {
                    $( "#sortable" ).sortable({
                        update : function () {
                            var order = $("#sortable").sortable("serialize");
                            $.ajax ({
                                url : 'ajax_sort.php',
                                data: order,
                                type: 'post',
                                success: function(data){
                                    alert(data);
                                }
                            });
                      }
                    });
            });
	</script><br />
    </head><br />
    <body></p>
<div id="sortable">
            <?php while ( $result = mysql_fetch_object($query) ){ ?></p>
<div class="handler" id="list_<?php echo $result->id; ?>&#8221;><br />
                <?php echo $result->name; ?>
            </div>
<p>            <?php } ?>
        </div>
<p>    </body><br />
</html><br />
[/php]</p>
<p style="text-align: justify;">Pada file ini tugas utamanya adalah melakukan menampilkan urutan awal yang datanya diambil dari database yang tadi value-nya sudah kita masukan. Untuk itu mari kita bedah bagian-bagian coding ini</p>
<h4>Loading data</h4>
<p>[php highlight_lines="3,5,8,9"]<br />
<?php<br />
/* connect to mysql databse */<br />
mysql_connect('localhost', 'root', $password);<br />
/* select the database */<br />
mysql_select_db('tutorial');</p>
<p>/* do some query selecting id and names order by ORDER asc */<br />
$str_query = "SELECT id,`name` FROM jqueryui_sort ORDER BY `order` ASC";<br />
$query = mysql_query($str_query)or die(mysql_error());<br />
?><br />
[/php]</p>
<blockquote><p>
<strong>Line 3</strong> : Connect ke mysql database terdiri dari 3 parameter: &#8220;database host&#8221;(ip/address),&#8221;database username&#8221;, &#8220;database password&#8221;<br />
<strong>Line 5</strong> : Memilih database (contoh saya menggunakan database bernama tutorial)<br />
<strong>Line 8</strong> :  Membuat query string ke database table &#8216;<em>jqueryui_sort</em>&#8216; untuk mengambil data nama dan &#8216;id&#8217; yang diurutkan berdasarkan field &#8216;order&#8217;<br />
<strong>Line 9</strong> : Menjalankan Query
</p></blockquote>
<p>Setelah itu kita print ke halaman web di bagian <body> :<br />
[php num="55" highlight_lines="57"]</p>
<div id="sortable">
            <?php while ( $result = mysql_fetch_object($query) ){ ?></p>
<div class="handler" id="list_<?php echo $result->id; ?>&#8221;><br />
                <?php echo $result->name; ?>
            </div>
<p>            <?php } ?>
        </div>
<p>[/php]</p>
<p style="text-align: justify;">Perhatikan saya menaruh <em>loop</em> di dalam <em>div </em>ber-&#8217;<em>id</em>&#8216; &#8220;<strong>sortable</strong>&#8220;. Dan juga perhatikan setiap tag <em>div</em> akan memiliki id bernama &#8220;<em>list_{<strong>pk_table</strong>}</em>&#8220;. Fungsi dari pemberian id disini akan berpengaruh pada nama index <strong>POST</strong> yang nanti diterima oleh file penerima proses nantinya. Sedangkan pemberian nomor/<em>primary key</em>(x) setelah tanda <em>underscrore</em>(_) berfungsi untuk menandakan bahwa record database &#8216;x&#8217; mendapat urutan &#8216;n&#8217;.</p>
<p style="text-align: justify;">Apabila kita coba jalankan dan kita view source-nya Anda akan melihat kurang lebih script di atas akan menghasilkan code seperti berikut pada tag body <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> :</p>
<p>[html]</p>
<div id="sortable">
<div class="handler" id="list_9">Jaclyn</div>
<div class="handler" id="list_3">George </div>
<div class="handler" id="list_8">Johanna </div>
<div class="handler" id="list_4">Joe </div>
<div class="handler" id="list_6">Nancy </div>
<div class="handler" id="list_1">Sigit </div>
<div class="handler" id="list_2">Karto </div>
<div class="handler" id="list_7">Alfonsus </div>
<div class="handler" id="list_5">Ciptanti </div>
</div>
<p>[/html] </p>
<p style="text-align: justify;">Code diatas mengatakan bahwa &#8216;Jaclyn&#8217; memiliki ID 9 di dalam table, dan seterusnya.</p>
<p>Setelah itu untuk memerintakan jQueryUI untuk mengubah content dalam &#8216;div&#8217; ber &#8216;id&#8217; &#8220;sortable&#8221; menjadi sebuah list yang dapat di urutkan dengan melakukan drag and drop, kita harus menambahkan script di bagian dalam tag header halaman ini.</p>
<p>[javascript num="37" highlight_lines="37,38,39,40,42,44,45,46,47,43"]<br />
            $(function() {<br />
                    $( &#8220;#sortable&#8221; ).sortable({<br />
                        update : function () {<br />
                            var order = $(&#8220;#sortable&#8221;).sortable(&#8220;serialize&#8221;);<br />
                            $.ajax ({<br />
                                url : &#8216;ajax_sort.php&#8217;,<br />
                                data: order,<br />
                                type: &#8216;post&#8217;,<br />
                                success: function(data){<br />
                                    alert(data);<br />
                                }<br />
                            });<br />
                      }<br />
                    });<br />
            });<br />
[/javascript]</p>
<blockquote><p>
<strong>Line 37</strong> : fungsi singkat alternatif dari &#8220;$().ready(function(){ &#8230; })&#8221; yang berfungsi untuk menjalankan script saat seluruh halaman sudah terload(exclude image, object )<br />
<strong>Line 38</strong> : memberi perintah untuk mengubah div ber-id &#8216;sortable&#8217; menjadi sebuah sortable list.</p>
<p>Banyak option yang dapat digunakan dalam modul sortable ini, tetapi karena kita hanya akan melakukan update record ke database apabila saat urutan diubah, maka kita akan <em>bind event</em> saat terjadi update urutan saja.</p>
<p><strong>Line 39</strong> : Mengeset callback function saat terjadi update<br />
<strong>Line 40</strong> : Memasukan urutan yang baru ke dalam sebuah string yang akan kita kirim ke server dengan menggunakan AJAX.</p>
<p>Pada line ke 40, option &#8220;<strong><em>serialize</em></strong>&#8221; akan mengembalikan nilai urutan baru ke dalam format query string:<br />
contohnya:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">list[]=9&amp;list[]=3&amp;list[]=8 ....</div></div>
<p><strong>Line 41 &#8211; 48</strong> : ajax Call dengan parameter sbb:</p>
<ol>
<li>Line 42: Alamat file untuk memproses data, apabila menggunakan fasilitas friendly URL dalam beberapa framework PHP, berilah full path-nya</li>
<li>Line 43: Data yang akan dikirim, kita kirim data yang sudah di <em>serialize</em> pada line 40</li>
<li>Line 44: type send data, kita set ke POST</li>
<li>Line 45-47 : mengeset Callback function saat sukses mengirimkan data dan proses selesai, dimana variable &#8216;<em>data</em>&#8216; berisi value yang dikembalikan oleh AJAX request. Untuk simplenya disini kita akan memberi tahu user kalau proses sort sudah selesai dengan memunculkan &#8216;<em>alert</em>&#8216; box.</li>
</ol>
</blockquote>
<p>Untuk sedikit pemanis, tambahkan sedikit CSS agar terlihat menarik <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /><br />
[css num="24"]</p>
<style>
            .handler{
                border: solid 1px #2b81af;
                padding: 5px;
                margin: 2px 0px 0px 2px;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
                border-radius: 5px;
                background-color: #fff;
                cursor: pointer;
            }
	</style>
<p>[/css]<br />
<strong>NB:</strong><em> Gunakan browser support CSS3<img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></em></p>
<h4 style="padding-top:20px;"><strong>File Proses</strong></h4>
<p>Untuk file prosesnya, buatlah file bernama &#8216;<em>ajax_sort.php</em>&#8216;(disesuaikan dengan yang terdapat pada syntax javascript AJAX pada parameter &#8216;<em>url</em>&#8216;), lalu isi dengan code berikut ini:</p>
<p>[php]<br />
<?php<br />
/* connect to mysql databse */<br />
mysql_connect('localhost', 'root', $password);<br />
/* select the database */<br />
mysql_select_db('tutorial');</p>
<p>/* get parameters */<br />
$sort_result = $_POST['list'];</p>
<p>/* make sure it's array  */<br />
if ( is_array($sort_result) )<br />
{<br />
    foreach ($sort_result as $index => $value)<br />
    {<br />
        /* prepare update statement */<br />
        $str_query = &#8220;UPDATE jqueryui_sort SET `order`=&#8217;&#8221; . (intval($index)+1) . &#8220;&#8216; WHERE id = &#8216;&#8221; . intval($value) . &#8220;&#8216;&#8221;;<br />
        mysql_query($str_query);<br />
    }</p>
<p>    echo &#8220;sort success&#8221;;<br />
}</p>
<p>?><br />
[/php]</p>
<p>file ini lebih sederhana dibandingkan frontpagenya karena tugasnya hanya menerima data yang dikirim oleh AJAX request dari file &#8216;sort.php&#8217; untuk kemudian di loop dan melakukan update di database. Berikut adalah keterangan-keterangannya:</p>
<blockquote><p>
<strong>Line 3&#038;5</strong> : Sama seperti dalam file &#8216;sort.php&#8217; digunakan untuk <em>connecting</em> ke database dan memilih database &#8216;<em>tutorial</em>&#8216;<br />
<strong>Line 8</strong> : Menerima parameter kiriman dari AJAX dengan index &#8216;<em>list</em>&#8216; ingat dengan id di list di file fron-end? setiap row kita beri id &#8216;<em>list_{pk_value}</em>&#8216; disinilah pengaruhnya, apabila id-nya kita beri nama misalnya &#8220;abcd_{pk_value}&#8221;, maka index yang kita retrieve akan berada di &#8216;abcd&#8217;. Yang diterima disini berupa array.<br />
<strong>Line 11</strong> : Untuk mengecek saja, karena yang dikirim harus array terlebih kita akan melakukan perulangan foreach(yang mana membutuhkan array dan apabila yang diberikan bukan array maka akan menghasilkan error).<br />
<strong>Line 13</strong> : Melakukan perulangan/<em>loop</em> dengan menggunakan foreach untuk me-<em>loop</em> array yang diterima dari AJAX, intuk index/urutan arraynya dimasukan ke dalam variable &#8216;<em>$index</em>&#8216; dan value-nya(Yang mana berisi primary key dari amsing-masing row) dimasukan ke variable &#8216;<em>$variable</em>&#8216;.<br />
<strong>Line 16</strong> : Membuat  string SQL untuk mengupdate database dengan urutan baru. Logikanya kita sudah mendapatkan urutan yang baru(disimpan dalam <em>variable</em> &#8216;<em>$index</em>&#8216; ) untuk row yang ber-<em>primary key $value</em> sehingga SQL query-nya akan menjadi:<br />
[sql]UPDATE jqueryui_sort SET `order`=&#8217;&#8221; . (intval($index)+1) . &#8220;&#8216; WHERE id = &#8216;&#8221; . intval($value) . &#8220;&#8216;[/sql]<br />
Supaya afdol untuk index-nya saya tambahkan 1 agar tidak ada urutan nol(karena yang di-<em>retrieve</em> ini arraynya mulai dari <em>index </em>0)<br />
<strong>Line 17</strong> : <em>Executing query</em> yang dibuat di line 16 <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /><br />
<strong>Line 20</strong> : Meresponse hasil agar dikembalikan ke user.
</p></blockquote>
<p>Setelah selesai, sekarang cobalah buka file sort.php melalui browser (kalau dalam contoh saya ada di dalam folder <strong><em>try/jquery_ui</em></strong> sehingga saya menggunakan alamat : <em>http://localhost/try/jquery_ui/sort.php</em>). Cobalah drag salah satu item yang ada disana dan lepaskan di urutan baru, tunggulah sesaat sampai ada pesan di browser mengatakan &#8220;Sort success&#8221;.  Atau hasilnya seperti pada gambar berikut ini <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div id="attachment_4087" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/result_sort_drag.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/result_sort_drag-450x360.jpg" alt="Saat item di drag untuk sorting" title="Saat item di drag untuk sorting" width="450" height="360" class="size-medium wp-image-4087" /></a><p class="wp-caption-text">Klik salah satu row dan drag ke urutan baru...</p></div>
<div id="attachment_4086" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2012/01/result_done.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2012/01/result_done-450x360.jpg" alt="Pesan bahwa sort sudah selesai" title="Pesan bahwa sort sudah selesai" width="450" height="360" class="size-medium wp-image-4086" /></a><p class="wp-caption-text">Saat dilepas, maka AJAX call akan dijalankan(lihat frame Firebug di bagian bawah mengirim variable urutan barunya), dan setelah selesai di proses server, akan memberikan pesan sukses seperti di atas</p></div>
<h4 style="padding-top:20px;"><strong>Kesimpulan</strong></h4>
<p>Tutorial ini memberikan gambaran bagaimana mudahnya membuat sebuah interface yang interaktif dalam memberikan urutan untuk mengurutkan sebuah list dengan menarik dan pastinya akan mempermudah user. Apabila tanpa bantuan jQuery dan jQUery UI, sudah dipastikan pembuatan interface seperti ini akan memakan waktu lama. Tetapi dengan menggunakan jQuery UI amat sangat mempermudah pembuatan user interface yang amat menarik ini.</p>
<p>Akhirnya semoga berguna dalam pekerjaan rekan-rekan &#8230; Thanks <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<div class="download_box">
<a href="http://download.rizkhey.net/view.php?file=tutorial_file/jquery_ui_sort_tutorial.zip" title="jQuery UI Sortable AJAX tutorial source code">Source Code</a>
</div>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=4066&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2012/01/4066-interactive-dragdrop-sorting-with-jqueryui-ajax/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Tutorial] Web Services using XMLRPC with PHP</title>
		<link>http://neo.rizkhey.net/2011/08/3953-tutorial-web-services-using-xmlrpc-with-php</link>
		<comments>http://neo.rizkhey.net/2011/08/3953-tutorial-web-services-using-xmlrpc-with-php#comments</comments>
		<pubDate>Thu, 11 Aug 2011 05:00:39 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[xmlrpc]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3953</guid>
		<description><![CDATA[
Web Services, mungkin sudah sering terdengar ungkapan ini, tetapi sekitar 2-3 bulan lalu akhirnya saya menggunakannya dalam lingkungan project. Singkatnya banyak sekali aplikasi berbasiskan web dengan berbagai macam latar belakang platform, dan juga OS. Celakanya adalah mereka terkadang tidak memberi akses ke database yang digunakan(atau mungkin gw ga tau DB apa yang mereka gunakan), mereka [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a title="XMLRPC" href="http://my.rizkhey.net/files/xmlrpc_img.jpg"><img class="aligncenter" title="XMLRPC" src="http://my.rizkhey.net/files/ext_thumb_xmlrpc_img.jpg" alt="XMLRPC" width="450" height="295" /></a></p>
<p style="text-align: justify;">Web Services, mungkin sudah sering terdengar ungkapan ini, tetapi sekitar 2-3 bulan lalu akhirnya saya menggunakannya dalam lingkungan project. Singkatnya banyak sekali aplikasi berbasiskan web dengan berbagai macam latar belakang platform, dan juga OS. Celakanya adalah mereka terkadang tidak memberi akses ke database yang digunakan(atau mungkin gw ga tau DB apa yang mereka gunakan), mereka hanya memberikan sebuah interface untuk menerima atau mengirim data. Secara programing agaknya ga mungkin kita melakukan parsing HTML saja karena kita tidak bisa mendapatkan data dari si sumber data, kalaupun bisa, hasilnya tidak akan akurat.</p>
<p style="text-align: justify;">Dari sinilah lahir namanya web services. Dulu jaman kuliah, web services ini pernah disinggung waktu belajar ASP.net hanya saat itu masih <em>blurry</em>, saya tidak ngerti fungsinya karena dosen cuman menjelaskan bagaimana buatnya dan gunanya untuk transfer data ke system lain, tetapi dosen tidak memberikan contoh paling tidak saat dua cross platform saling bertukar data melalui web services tersebut sehingga paling tidak saya ada gambaran.</p>
<p style="text-align: justify;">Ada beberapa jenis metode menggunakan web service. Paling sederhana adalah XMLRPC dan yang lebih advanced adalah SOAP. keduanya menggunakan media format XML untuk bertukar data. Dalam tutorial ini, saya akan mencoba menerangkan penggunaan XMLRPC dalam PHP menggunakan sebuah library yang sangat sederhana yang dapoat diambil <a href="http://www.keithdevens.com/software/xmlrpc/ ">disini</a>.</p>
<p style="text-align: justify;">XMLRPC sendiri sudah banyak yang menggunakannya walau belum dipatentkan oleh W3C, contohnya oleh WordPress(dengan blogging aplikasinya seperti halnya di Microsoft Word 2007  atau ada juga aplikasi untuk OS mobile seperti Android, iPhone, etc), bloger, etc.</p>
<p style="text-align: justify;">Tutorial akan terbagi menjadi 2 bagian besar, yaitu <em>Bagian Server</em> dan <em>Bagian Client</em>. Bagian Client nanti akan merequest ke Server sebuah action dengan mengirim parameter atau hanya sekedar merequest saja, sedangkan server akan menerima request dan melakukan proses. Apabila Method/action yang diminta terdaftar maka server akan melakukan tugasnya dan mereturn sesuatu untuk kembali dibaca oleh si client, apabila method yang diinginkan tidak terdaftar maka server akan mengembalikan error value.</p>
<p><span id="more-3953"></span></p>
<blockquote style="text-align: justify;"><p>Yang dibutuhkan dalam tutorial ini adalah:</p>
<ol>
<li>Web Server Apache + PHP (simple, using XAMPP kalau tidak tahu cara installnya)</li>
<li>XML-RPC Library for PHP (<a href="http://keithdevens.com/software/xmlrpc" target="_blank">download disini</a>)</li>
<li>Text editor seperti Notepad++ atau Adobe Dreamweaver atau Notepad biasa apabila terpaksa <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /></li>
</ol>
</blockquote>
<p style="text-align: justify;">Sebelum memulai tutorial ini ada baiknya kita membuat sebuah folder di dalam folder di folder <strong><em>htdocs</em></strong>(apabila menggunakan XAMPP) dnegan nama &#8220;<strong><em>xmlrpc</em></strong>&#8221; kemudian buatlah 2 buah folder lagi di dalamnya bernama &#8220;<strong><em>server</em></strong>&#8221; dan &#8220;<strong><em>client</em></strong>&#8221; dimana nantinya folder <em><strong>server </strong></em>akan berisi file untuk <em>XMLRPC-server side</em> dan folder <em><strong>client</strong></em> akan berisi file-file untuk <em>XMLRPC-client side</em>.</p>
<p style="text-align: justify;">Kemudian buatlah sebuah database mysql baru(dalam contoh ini saya menggunakan nama database &#8216;<em><strong>tutorial</strong></em>&#8216;) dan import <a href="http://download.rizkhey.net/view.php?file=script/xmlrpc/tutorial.sql.gz">file dump ini</a> ke dalam mysql.</p>
<h2 style="text-align: justify;">SERVER SIDE</h2>
<p style="text-align: justify;">Copy-kan file XML-RPC Library yang sudah di download ke folder server. Dan rename menjadi &#8220;xmlrpc-func.php&#8221;. Kemudian logikanya karena Server nantinya yang akan berhubungan dengan database, maka kita harus buat sebuah file yang akan mempersiapkan koneksi ke database dan juga meng-include semua library yang kita buat nantinya.</p>
<p style="text-align: justify;">Sebelumnya kita buat dulu 3 php file dengan nama &#8220;index.php&#8221;, &#8220;xmlrpc_proc.php&#8221;, &#8221;app_load.php&#8221;. Sehingga susunan isi folder akan menjadi seperti berikut ini:</p>
<p style="text-align: justify;"><img class="aligncenter" title="Susunan Folder Server side" src="http://my.rizkhey.net/files/content.JPG" alt="" width="181" height="104" /></p>
<p style="text-align: justify;">Funsgi masing-masing file adalah sbb:</p>
<ol style="text-align: justify;">
<li><em><strong>app_load.php</strong></em>: akan melakukan koneksi ke database, dan menginclude library file serta file yang berisi fungsi-fungsi yang akan di execute oleh XMLRPC server.</li>
<li><em><strong>index.php</strong></em>: index file yang akan menjadi front-end XMLRPC server. Semua request untuk XMLRPC akan menuju ke file ini.</li>
<li><em><strong>xmlrpc-func.php</strong></em>: Library XMLRPC yang dibuat oleh Keith Devens.</li>
<li><em><strong>xmlrpc_proc.php</strong></em>: adalah file berisi method-method/action yang dapat dipanggil oleh client.</li>
</ol>
<p style="text-align: justify;">Okay, pertama-tama mari kita buat dulu isi untuk file <em><strong>app-load.php</strong></em>. Fungsi utama file ini adalah seperti dituliskan diatas, yaitu mengkoneksikan ke database, dan meng-include file-file library yang dibutuhkan.</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 460px;">
<dt class="wp-caption-dt"><a title="XMLRPC Tutorial" href="http://my.rizkhey.net/files/1_app_load.JPG"><img title="XMLRPC Tutorial" src="http://my.rizkhey.net/files/ext_thumb_1_app_load.JPG" alt="XMLRPC Tutorial" width="450" height="274" /></a></dt>
<dd class="wp-caption-dd">app_load.php file content</dd>
</dl>
</div>
<p style="text-align: justify;">Penjelasan:</p>
<blockquote style="text-align: justify;">
<p style="text-align: justify;">Line 10 : connect ke mysql<br />
Line 11 : memilih database &#8220;tutorial&#8221;<br />
Line 12 : including xmlrpc library<br />
Line 21 : Including xmlrpc server action/method</p>
</blockquote>
<p style="text-align: justify;">Save file tersebut kemudian sekarang kita akan buat content file kedua yaitu &#8220;<em><strong>xmlrpc_proc</strong></em>&#8220;. File ini akan berisi 4 buah fungsi. Tiga fungsi untuk method/action yang digunakan oleh XMLRPC melayani request dari client dan 1 adalah fungsi untuk mereturn pesan error saat method/action yang direquest tidak terdaftar.</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 449px;">
<dt class="wp-caption-dt"><a title="XMLRPC" href="http://my.rizkhey.net/files/xmlrpc_proc.gif"><img title="XMLRPC" src="http://my.rizkhey.net/files/xmlrpc_proc.gif" alt="XMLRPC" width="439" height="600" /></a></dt>
<dd class="wp-caption-dd">xmlrpc_proc.php content</dd>
</dl>
</div>
<p style="text-align: justify;">Bagian yang penting dalam file ini:</p>
<blockquote style="text-align: justify;">
<ol>
<li><strong>Line 6 &#8211; 10</strong> : kita daftarkan method yang dapat diakses oleh client dalam variable &#8220;$xmlrpc_methods&#8221;. Dimana key array merupakan nama alias fungsi method/action untuk client, sedangkan valuenya merupakan nama fungsi internal yang akan diexecute oleh XMLRPC.</li>
<li><strong>Line 15</strong> : merupakan <em><strong>function get_sum_data</strong></em>, yang nantinya akan berfungsi untuk pemanggilan request method &#8220;<em><strong>exec.get_sum_data</strong></em>&#8221; oleh client yang akan mengembalikan jumlah record dalam database.</li>
<li><strong>Line 23</strong> : fungsi untuk memberikan response ke client dengan mengembalikan value yang direquest dalam fungsi ini(jumlah record dalam table database).</li>
<li><strong>Line 29</strong>: fungsi <em><strong>load_list_limit</strong></em>, digunakan untuk mengambil data sejumlah yang direquest dari client(apabila method yang direquest adalah &#8216;<em><strong>exec.module_load_all_list_limit</strong></em>&#8216;). Dalam fungsi ini, fungsi menerima parameter berjenis array dimana index &#8217;0&#8242; berisi offset data mulai akan mulai diambil. Sedangkan offset &#8217;1&#8242; merupakan jumlah data yang akan diambil.</li>
<li><strong>Line 43</strong>: mengembalikan response ke client dengan jenis array berisi hasil query sejumlah yang dihasilkan berdasarkan parameter yang dikirimkan.</li>
<li><strong>Line 49</strong>: merupakan <em><strong>function load_single</strong></em>. Yang mana diexecute apabila client merequest method/action &#8220;<em><strong>exec.module_load_single</strong></em>&#8221; fungsinya adalah untuk mengambil detail 1 row dari data. Fungsi ini menerima 1 buah parameter berjenis integer yang merupakan <em><strong>primary key value row</strong></em> yang akan diambil.</li>
<li><strong>Line 53</strong>: di line 51 kita validasikan apakah id yang terkirim adalah berupa numerik atau bukan. Apabila bukan maka kita harus response kembali ke client sebuah pesan error. Maka di line 53 ini adalah contoh memberikan respons ke client untuk [pesan error, kita beri error number 3 untuk ini(Nomor error dapat dimodifikasi sesuai selera Anda <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> ).</li>
<li><strong>Line 61</strong>: Mengirimkan response ke client berisi data detail satu buah row yang direquest oleh client.</li>
<li><strong>Line 65</strong>: fungsi <strong>XMLRPC_method_not_found</strong>, dimana fungsi ini akan di-execute apabila method/action yang direquest tidak ditemukan.</li>
</ol>
</blockquote>
<p style="text-align: justify;">Save file tersebut. Sekarang mari kita buat file untuk front-end XMLRPC servernya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: justify;">Bukalah file "index.php" dan isilah contentnya seperti berikut ini:</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 509px;">
<dt class="wp-caption-dt"><a title="xmlrpc" href="http://my.rizkhey.net/files/index.gif"><img title="xmlrpc" src="http://my.rizkhey.net/files/index.gif" alt="xmlrpc" width="499" height="685" /></a></dt>
<dd class="wp-caption-dd">index.php file content</dd>
</dl>
</div>
<p style="text-align: justify;">Keterangan isi file:</p>
<blockquote style="text-align: justify;">
<ol>
<li><strong>Line 10 </strong>: meng-include semua library yang sudah di load dalam file "app_load.php".</li>
<li><strong>Line 12</strong>: melakukan parsing XML terhadap request post.</li>
<li><strong>Line 16</strong>: mengambil nama method yang direquest oleh client</li>
<li><strong>Line 22</strong>: Mendapatkan parameter yang dikirim oleh Client.</li>
<li><strong>Line 33</strong>: kita cek apakah method yang diminta oleh client(lihat line 16), terdaftar atau tidak.</li>
<li><strong>Line 35</strong>: Apabila method/action yang direquest tidak ada, maka panggil fungsi untuk meresponse dengan fungsi "XMLRPC_method_not_found" supaya client tahu bahwa method/action yang dia request tidak ditemukan.</li>
<li><strong>Line 41-45</strong>: Apabila Method ditemukan maka panggil alias fungsi alias dari method yang direquest oleh client beserta parameter yang dikirimkan.</li>
</ol>
</blockquote>
<p style="text-align: justify;">Awalnya saya bingung bagaimana PHP bisa memanggil fungsi kalau kita tahu nama fungsinya dalam string seperti contoh di atas? Setelah mencari tahu, PHP memiliki keunikan yang bisa dibilang cukup praktis. cobalah coding berikut ini:</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 514px;">
<dt class="wp-caption-dt"><img style="border: 1px solid black;" title="Trick PHP" src="http://my.rizkhey.net/files/cheatsheet.gif" alt="" width="504" height="221" /></dt>
<dd class="wp-caption-dd">Execute Function dari Nama Function dalam String Variable</dd>
</dl>
</div>
<p style="text-align: justify;">Cara ini selain dapat digunakan untuk function, dapat juga untuk classes dan juga variable sendiri <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: justify;">Apabila Anda mengaksesnya ke alamat: 'http://localhost/xmlrpc/server/' Maka Anda akan melihat seperti ini dalam browser Anda:</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 502px;">
<dt class="wp-caption-dt"><img class=" " style="border: 1px solid black;" title="Tampilan Dalam Browser" src="http://my.rizkhey.net/files/server.gif" alt="" width="492" height="379" /></dt>
<dd class="wp-caption-dd">Server Side apabila dimunculkan dalam browser</dd>
</dl>
</div>
<p style="text-align: justify;">Okay, sampai sini XMLRPC server telah selesai kita buat, pada step berikutnya kita akan membuat Client yang merequest ke server ini.</p>
<h2 style="text-align: justify;">CLIENT SIDE</h2>
<p style="text-align: justify;">Sisi Client adalah bagian yang mana nantinya akan merequest ke server berdasarkan method-method yang diijinkan oleh server. Untuk memulai membuat client, coopy-kan file "<em><strong>xmlrpc-func.php</strong></em>" ke folder client, kemudian buatlah sebuah file bernama "index.php" di folder client sehingga isi dari folder client kurang lebih sebagai berikut.</p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 204px;">
<dt class="wp-caption-dt"><img style="border: 1px solid black;" title="XMLRPC Client" src="http://my.rizkhey.net/files/1_client_folder_content.gif" alt="" width="194" height="78" /></dt>
<dd class="wp-caption-dd">XMLRPC Client-side folder</dd>
</dl>
</div>
<p style="text-align: justify;">Bukalah file "<strong>index.php</strong><em>" kemudian isilah contentnya seperti berikut ini:</em></p>
<div class="mceTemp mceIEcenter" style="text-align: justify;">
<dl class="wp-caption aligncenter" style="width: 458px;">
<dt class="wp-caption-dt"><a href="http://my.rizkhey.net/files/client.gif" target="_blank"><img style="border: 1px solid black;" title="Client-side XMLRPC requesting code" src="http://my.rizkhey.net/files/client.gif" alt="" width="448" height="554" /></a></dt>
<dd class="wp-caption-dd">Isi dari "index.php" bukalah di halaman baru untuk melihat di ukuran aslinya(right click + open in new window)</dd>
</dl>
</div>
<p style="text-align: justify;">Keterangan file ini:</p>
<blockquote style="text-align: justify;">
<ol>
<li><strong>Line 7</strong>: Include Library yang dibutuhkan.</li>
<li><strong>Line 9</strong>: Masukan alamat host server XMLRPC. tanpa prefix "http://", apabila tidak menggunakan port http default(80), tambahkan pula disini. Misalkan alamat XMLRPC servernya adalah "<em><strong>http://www.xmlrpc-server.com:8080</strong></em>" maka masukan valuenya "<em><strong>www.xmlrpc-server.com:8080</strong></em>"</li>
<li><strong>Line 10</strong>: Masukan alamat tempat XMLRPC server berada, dalam kasus contoh tutorial ini: "/xmlrpc/server/index.php"</li>
<li><strong>Line 12</strong>: Optional, set  ke 1 apabila ingin mengaktifkan fasilitas debuging. Untuk melakukan debug, Anda dapat memanggil fungsi "<em><strong>XMLRPC_debug_print()</strong></em>" setelah merequest sesuatu dari server. Funsgi ini sangat baik untuk melakukan tracing error saat server mengembalikan value yang tidak semestinya(entah blank atau mengembalikan value true tetapi return valuenya kosong).</li>
<li><strong>Line 17-30</strong>: Contoh merequest method yang tidak mengirimkan parameter apapun, dan mengembalikan single value. pada Line 19: Melakukan request method/action '<em><strong>exec.get_sum_data</strong></em>' dan menampung return value dalam variable. Return variable dari fungsi ini selalu berupa array berisi 2 index. Index pertama akan mengembalikan value sukses atau tidaknya pemanggilan request. Apabila error dari server karena mugnkin method tidak ada, maka index pertama ini akan mengembalikan value <em><strong>FALSE</strong></em>, apabila berhasil maka akan mengembalikan value <em><strong>TRUE</strong></em>.<br />
<strong>CATATAN</strong>: terkadang apabila Server sukses dihubungi tetapi mungkina da salah syntax error, maka fungsi ini akan mengembalikan <em><strong>TRUE</strong></em> pada index pertama. Gunakan fungsi debuging untuk melihat error-nya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></li>
<li><strong>Line 37-50</strong>: Melakukan request dengan mengirimkan satu parameter tunggal. Request contohnya ada di line: 38. Result return value akan berupa array.</li>
<li><strong>Line 56-71</strong>: Contoh request method "<em><strong>exec.module_load_all_list_limit</strong></em>", dimana mengirimkan parameter berupa array. Value yang dikembalikan berupa array multidimensi.</li>
<li><strong>Line 74-84</strong>: Contoh request method/action yang tidak terdaftar pada server, yang kemudian akan mengembalikan pesan error.</li>
</ol>
</blockquote>
<p style="text-align: justify;">Apabila kita perhatikan dari contoh client ini, maka dapat dilihat untuk melakukan request ke server XMLRPC ini sungguh amat simple, yaitu hanya dengan memanggil sebuah fungsi bernama XMLRPC_requesst dengan detail:</p>
<blockquote style="text-align: justify;">
<p style="text-align: justify;">XMLRPC_request ($site, $location, $methodName,[[ $params = NULL], $user_agent = NULL])</p>
<ol>
<li><strong>$site</strong> : Berjenis string, berisi alamat IP atau host dari XMLRPC server</li>
<li><strong>$location</strong>: Berjenis string, berisi alamat ke XMLRPC server file. detailnya sbb:<br />
<img class="aligncenter" title="Keterangan" src="http://my.rizkhey.net/files/keterangan.gif" alt="" width="359" height="53" /></li>
<li><strong>$param</strong>: parameter yang dikirimkan, apabila berjenis array, gunakan fungsi &#8220;XMLRPC_prepare($arr_parameter_tobe_send)&#8221;</li>
<li><strong>$user_agent</strong>: User Agent alias</li>
</ol>
<p>Return value akan berupa array index pertama merupakan indikasi apakah request berhasil atau tidak.  Apabila berhasil, maka akan mengembalikan TRUE apabila tidak akan berisi FALSE*. Pada INdex berikutnya apabila berhasil, maka akan mengembalikan value yang dikembalikan dari XMLRPC server(dapat berupa string, integer, atau array, dll). Sedangkan apabila gagal akan mengembalikan array dengan 2 assosiasi index yang pertama adalah &#8220;<em><strong>faultCode</strong></em>&#8221; dan kedua adalah &#8220;<em><strong>faultString</strong></em>&#8221;</p>
<div style="border: solid 1px #fff; font-size: 11px; padding: 5px;">*Sekali lagi apabila request berhasil tetapi karena mungkin ada kesalah kode pada server sehingga terjadi error syntax, atau kita salah memasukan path Location, index pertama ini akan tetap mengembalikan BOOL TRUE. Tetapi index berikutnya return valuenya kosong. Gunakan Debuging function untuk memeriksa error ini.</div>
</blockquote>
<p style="text-align: justify;">Dalam prakteknya, XMLRPC tidak hanya saja untuk bertukar data berupa string seperti contoh di atas. Pada aplikasinya, saya juga menggunakannya untuk transfer data binnary(image, ms Word file, etc) yang berukuran kecil menengah(sekitar under 10MB). Caranya simple saja, kita hanya perlu membaca file yang hendak kita kirim (dengan menggunakan fungsi <em><strong>file_get_contents($filename)</strong></em> kemudian hasilnya kita encrypt dengan menggunakan <em><strong>base64_encode</strong></em>. kemudian string hasil encodingnya dikirim via XMLRPC, kemudian oleh XMLRPC server pada method penerima kita buat fungsi kecil untuk mendecrypt kembali base64 string dengan fungsi <em><strong>base64_decode</strong></em> kemudian hasil stringnya kita simpan ke dalam file dengan menggunankan fopen,fwrite,fclose seperti biasanya). Butuh diingat cara mengirim file binnary menggunakan XMLRPC tidaklah begitu optimal untuk file berukuran besar, terlebih karena melakukan enkripsi ke base64 akan membengkakan size-nya sekitar 30% lebih besar dari string aslinya. Sehingga apabila contohnya kita mengirim 10MB file maka dalam keadaan terenkripsi akan terkirim sekitar 13,5MB string file. tentunya ini dapat menyebabkan overload memory usage pada XMLRPC server. Tetapi apabila mengirim file berukuran kecil saya rasa XMLRPC dapat menghandlenya dengan baik(sekitar &lt;3MB).</p>
<p style="text-align: justify;">Yang perlu diperhatikan adalah transfer dalam XMLRPC, semua string akan dinormalisasi(menggunakan htmlentities), itulah sebabnya apabila kita mentransfer file binnary, kita harus mengencryptnya ke base64 terlebih dahulu agar string tidak dimodifikasi oleh XMLRPC library.</p>
<p style="text-align: justify;">Sekian kiranya tutorial kali ini, semoga berguna, akhir kata, semua file dalam tutorial ini, dapat di <strong><a href="http://download.rizkhey.net/view.php?file=script/xmlrpc/XMLRPC_tutorial.zip" target="_blank">download disini</a></strong>. Pastikan edit database connectionnya, serta di bagian client, edit  variable &#8220;$xmlrpc_server_host&#8221; dan &#8220;$xml_rpc_server_path&#8221;.</p>
<p style="text-align: justify;">Thankyou <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<blockquote>
<h4 style="text-align: justify;">Update &amp; addition</h4>
<p style="text-align: justify;">Beberapa pengunjung bertanya langsung pada saya karena program PHP meng-issue-kan warning saat XMLRPC dijalankan. Ini dikarenakan Call By reference pada PHP 5.3++ diberi label deprecated(will be removed in near future), tetapi bukan berarti error, PHP hanya memberitahukan bahwa pada versi-versi berikutnya(entah versi berapa) fasilitas ini akan dihilangkan. tetapi apabila Anda menggunakan library ini untuk urusan di website, Anda tidak perlu begitu kawatir, karena masih banyak yang menggunakan PHP 5.2 daripada PHP 5.3</p>
<p style="text-align: justify;">Untuk menyelesaikan masalah ini, apabila Anda menggunakan PHP 5.3.x (terutama yang menggunakan XAMPP) , Anda perlu merubah 1 buah value di &#8216;<strong><em>php.ini</em></strong>&#8216; pada value &#8216;<em>allow_call_time_pass_reference = off</em>&#8216; Ubah menjadi <em>&#8216;allow_call_time_pass_reference = On</em>&#8216;. Kemudian save file &#8216;<em><strong>php.ini</strong></em>&#8216; dan restart Apache. <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: center;"><a href="http://neo.rizkhey.net/wp-content/uploads/2011/08/turn_on.jpg"><img class="aligncenter size-medium wp-image-4039" title="turn it to &quot;on&quot;" src="http://neo.rizkhey.net/wp-content/uploads/2011/08/turn_on-450x149.jpg" alt="turn it to &quot;on&quot;" width="450" height="149" /></a></p>
<p style="text-align: justify;">
</blockquote>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3953&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2011/08/3953-tutorial-web-services-using-xmlrpc-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLSRV, native Microsoft SQL Server Extension for PHP</title>
		<link>http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php</link>
		<comments>http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php#comments</comments>
		<pubDate>Tue, 26 Apr 2011 10:49:21 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[SQL server]]></category>
		<category><![CDATA[sqlsrv]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3913</guid>
		<description><![CDATA[
Sudah berapa lama  saya  ga update blog ini? 1 bulan? maybe. Tidak terasa  saya  masuk di penghujung kontrak di perusahaan  saya  sekarang. Akhir tidaklah buruk, beberapa ilmu baru dari proyek terakhir terus berdatangan. Kali ini  saya  mencoba sharing sebuah extension PHP yang native dibuat oleh Microsoft sendiri, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" title="Microsoft SQL Server" src="http://my.rizkhey.net/files/Logo_Ms_SQL4.jpg" alt="" width="450" height="281" /></p>
<p style="text-align: justify;">Sudah berapa lama  saya  ga update blog ini? 1 bulan? maybe. Tidak terasa  saya  masuk di penghujung kontrak di perusahaan  saya  sekarang. Akhir tidaklah buruk, beberapa ilmu baru dari proyek terakhir terus berdatangan. Kali ini  saya  mencoba sharing sebuah extension PHP yang native dibuat oleh Microsoft sendiri, yaitu &#8220;sqlsrv&#8221;.</p>
<p style="text-align: justify;">Beberapa waktu lalu,  saya  sempat mendownload versi XAMPP untuk developing(versi 1.7.4) niatnya untuk mengecek kompitabilitas program  saya  supaya selalu up to date, dan apabila terbentur suatu kondisi,  saya  bisa cepat memikirkan jalan keluarnya. Kebetulan tantangan langsung muncul. Yap, terhitung dari XAMPP versi 1.7.4 dengan PHP 5.3.5++ PHP sudah tidak menyediakan driver untuk SQL server lagi(sebelumnya ada &#8216;mssql.dll&#8217; di folder &#8220;ext&#8221;, tetapi kini sudah tidak ada). Sehingga kalau tidak mau usaha, ok aplikasi  saya  akan stuck development di XAMPP 1.7.3 ke bawah. Atau menggunakan model ODBC( saya  kurang suka pake ODBC walau Database Abstraction Layer  saya  mendukung hal itu).</p>
<p><span id="more-3913"></span></p>
<p style="text-align: justify;">Beberapa post sebelumnya,  saya  pernah <a href="http://neo.rizkhey.net/2012/01/4100-emulate-microsoft-sql-server-select-limit2005-and-above">menyinggung hal ini</a>. Karena Microsoft mengembangkan sendiri drivernya, akhirnya PHP developer melepaskan dan mempercayakan kepada yang empunya DBMS <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> Singkat kata Microsoft punya driver yang diberi nama &#8220;sqlsrv&#8221; atau native driver Ms SQL Server.</p>
<p style="text-align: justify;">Installasinya karena &#8220;baunya&#8221; dari Microsoft  saya  pikir awalnya rumit( saya  ga gitu banyak kenangan baik dengan devekloping tools Microsoft <img src='http://neo.rizkhey.net/smilies/yahoo_sad.gif' alt='&#58;&#40;' class='wp-smiley' width='18' height='18' title='&#58;&#40;' /> ). Ternyata kali ini lebih mudah dari install extension Imagemagick <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /> Kurang lebih beginilah caranya( saya  coba di XAMPP versi 1.7.3):</p>
<ol>
<li>Download Extensionnya di <a href="http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05" target="_blank">sini</a>.</li>
<li>Pastikan PC dimana PHP terinstall memiliki &#8220;Microsoft SQL Server Native Client&#8221;(terutama SQL server 2008 Native Driver).<br />
Driver ini akan terinstall apabila di PC terinstall Visual Studio 2008(Baik express atau yang full package) atau SQL server 2008. Apabila tidak punya, bisa download di <a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c6c3e9ef-ba29-4a43-8d69-a2bed18fe73c" target="_blank">halaman ini</a>(Scroll bagian bawah atau cari bagian &#8220;<em>Microsoft SQL Server 2008 Native Client</em>&#8220;), download sesuai arsitektur OS yang dipakai(32 atau 64 bit) kemudian Install.</li>
<li>Buka installer program SQL Server Extension for PHP yangs udah di download. Dia akan menanyakan hendak diekstract dimana file nantinya(dia hanya minta extract tidak ada proses install).</li>
<li style="text-align: justify;">Buka folder dimana file ter-extract, maka akan banyak sekali file-file disana(terutama versi untuk <em>dll</em> file-nya). <del datetime="2012-01-12T03:20:31+00:00">Seperti yang seharusnya diingat, bahwa apabila kita menggunakan APACHE sebagai web server, maka kita memilih extension yang di compile dengan Visual C versi 6(VC6), sedangkan apabila menggunakan IIS, kita menggunakan extension yang dicompile dengan Visual C versi 9</del>.<br />
<blockquote><p>Mulai dari PHP 5.3.6 semua PHP menggunakan VC9, sehingga cek versi PHP Anda karena Apache 2 build baru juga telah menggunakan VC9(including latest XAMPP juga sudah menggunakan yang sudah di compile menggunakan VC9).</p>
<div id="attachment_4114" class="wp-caption aligncenter" style="width: 460px"><img src="http://neo.rizkhey.net/wp-content/uploads/2011/04/vc9-450x257.jpg" alt="PHP 5.3.8 Dijalankan di Apache 2 VC 9" title="PHP 5.3.8 Dijalankan di Apache 2 VC 9" width="450" height="257" class="size-medium wp-image-4114" /><p class="wp-caption-text">Contoh PHP 5.3.8 Dijalankan di Apache 2 VC 9, statusnya dapat diliat di halaman phpinfo</p></div>
<p>Apabila versi PHP Anda pilih yang menggunakan VC9 bukan yang VC6</p></blockquote>
<p>Dalam paketnya juga terdapat sebuah file help dokumentasi a&#8217;la dokumentasi PHP yang bisa digunakan untuk referensi fungsi-fungsi dalam extension <em>sqlsrv</em>.</p>
<p><div class="wp-caption aligncenter" style="width: 215px"><img title="SQLSRV" src="http://my.rizkhey.net/files/sqlsrv.JPG" alt="File hasiL Extract" width="205" height="348" /><p class="wp-caption-text">File hasiL Extract</p></div></li>
<li>Copy &#8220;<strong>php_sqlsrv_53_ts_vc6/9.dll</strong>&#8221; ke directory extension PHP(Semenjak XAMPP yang  saya  gunakan adalah versi 1.7.3 yang memiliki versi PHP 5.3.x maka yang dipilih adalah &#8216;php_sqlsrv_53_ts_vc6/9.dll&#8217;).</li>
<li>Buka file &#8220;<strong>php.ini</strong>&#8221; dalam folder PHP, tambahkan satu baris di bagian extension PHP untuk memanggil extension <em>sqlsrv</em>.Save kemudian Tutup file &#8220;php.ini&#8221;, kemudian restart Apache.
<p><div class="wp-caption aligncenter" style="width: 380px"><img title="Add line" src="http://my.rizkhey.net/files/addline.JPG" alt="Tambahkan Line untuk memanggil Extension SQLSrv" width="370" height="98" /><p class="wp-caption-text">Tambahkan Line untuk memanggil Extension SQLSrv</p></div></li>
<li>Pergilah ke halaman phpinfo(apabila menggunakan XAMPP) biasanya ada di alamat: &#8216;http://localhost/xampp/phpinfo.php&#8217; carilah sqlsrv. Apabila Anda berhsail, maka akan muncul di dalam list extension PHP yang aktif
<div class="wp-caption aligncenter" style="width: 460px"><a title="SQL server native driver active" href="http://my.rizkhey.net/files/sqlsrv_active.JPG"><img title="SQL server native driver active" src="http://my.rizkhey.net/files/ext_thumb_sqlsrv_active.JPG" alt="SQL server native driver active" width="450" height="223" /></a><p class="wp-caption-text">Extension sqlsrv Aktif di halaman phpinfo</p></div>
<p style="text-align: center;">
</li>
<li>Coba jalankan beberapa code sqlsrv untuk test, simplenya  saya  gunakan code seperti ini
<div class="wp-caption aligncenter" style="width: 460px"><a href="http://my.rizkhey.net/files/testCode.JPG"><img title="Contoh Code Untuk mengetest" src="http://my.rizkhey.net/files/ext_thumb_testCode.JPG" alt="Contoh Code Untuk mengetest" width="450" height="208" /></a><p class="wp-caption-text">Contoh Code Untuk mengetest</p></div>
<p>Apabila hasilnya keluar tanpa ada error, maka Anda berhasil menginstall extension sqlsrv.</li>
</ol>
<p style="text-align: justify;">Yang perlu diperhatikan disini adalah Pada field/column yang berjenis DATETIME, akan dikembalikan dalam bentuk Object berisi <em>value</em>-nya sendiri, <em>timezone type</em> dan  juga <em>timezone</em>-nya. Selain itu apabila Anda menggunakan ADODB sebagai abstraction layer untuk database, driver yang Anda bisa gunakan adalah &#8220;<em><strong>mssqlnative</strong></em>&#8220;.</p>
<p style="text-align: justify;">Tetapi bukan tanpa pekerjaan, ADODB &#8220;<em>mssqlnative</em>&#8221; driver mengembalikan value tanpa array untuk jenis DATETIME, hanya saja di sisipi dengan huruf  &#8220;T&#8221; sebagai seperasi pemisah antara tanggal dan waktu(biasanya spasi) dan diakhiri dengan huruf &#8220;Z&#8221;.</p>
<p style="text-align: justify;">Intinya  saya  belum tahu apa maksudnya itu(maklum telmi), Anda bisa mengeditnya di file &#8220;adodb-mssqlnative.inc.php&#8221; di folder &#8220;<em><strong>drivers</strong></em>&#8221; di dalam folder ADODB. Sekitar line 788 hapus &#8220;\T&#8221; ganti dengan spasi  dan juga hapus &#8220;\Z&#8221;.</p>
<p style="text-align: justify;">Apabila Anda tidak menggunakan ADODB for PHP, dan Anda ingin agar return value kolom berjenis DATETIME di return sebagai string, maka tambahkan satu parameter di saat membuat koneksi ke sqlsrv. Contoh sbb:</p>
<p>[php highlight_lines="3"]<br />
<?php<br />
$serverName = "MyServer";<br />
$connectionInfo = array( "Database"=>&#8220;AdventureWorks&#8221;, &#8216;ReturnDatesAsStrings &#8216;=> true);<br />
$conn = sqlsrv_connect( $serverName, $connectionInfo);<br />
if( $conn === false )<br />
{<br />
   echo &#8220;Could not connect.\n&#8221;;<br />
   die( print_r( sqlsrv_errors(), true));<br />
}</p>
<p>sqlsrv_close( $conn);<br />
?><br />
[/php]</p>
<p style="text-align: justify;">SQL native driver ini menurut yang  saya  baca menggunakan odbc yang sudah dioptimalisasikan oleh Microsoft. Dan semenjak extension ini dibuat oleh Microsoft, sehingga akan dimaintain oleh Microsoft.</p>
<p style="text-align: justify;">Untuk beberapa sumber bacaan yang menarik:</p>
<ul>
<li><a href="http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx" target="_blank">mssql vs. sqlsrv: What’s the Difference? (Part 1)</a></li>
<li><a href="http://blogs.msdn.com/b/brian_swan/archive/2010/03/10/mssql-vs-sqlsrv-what-s-the-difference-part-2.aspx">MSSQL vs. SQLSRV: What’s the Difference? (Part 2)</a></li>
</ul>
<p style="text-align: justify;">Sekian tutorial kali ini&#8230; semoga berguna <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3913&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2011/04/3913-sqlsrv-native-microsoft-sql-server-extension-for-php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Uploading, Sending POST data Via CURL in PHP</title>
		<link>http://neo.rizkhey.net/2010/12/3764-uploading-sending-post-data-via-curl-in-php</link>
		<comments>http://neo.rizkhey.net/2010/12/3764-uploading-sending-post-data-via-curl-in-php#comments</comments>
		<pubDate>Tue, 14 Dec 2010 04:06:31 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3764</guid>
		<description><![CDATA[
Dalam pengembangan sebuah web based program terkadang ada kalanya kita membuat &#8216;bridge&#8217; atau sebuah jembatan yang mengubungkan 2 system atau 2 aplikasi pada 2 server terpisah. Tak jarang tidak hanya bertukar data yang bersifat text tetapi juga bertukar data binary seperti halnya pengiriman gambar atau file-file lain dari satu system ke system yang lain yang [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://neo.rizkhey.net/wp-content/uploads/2010/12/image.jpg"><img class="aligncenter size-medium wp-image-3765" title="Upload, Sending Data Via CURL" src="http://neo.rizkhey.net/wp-content/uploads/2010/12/image-450x284.jpg" alt="Upload, Sending Data Via CURL" width="450" height="284" /></a></p>
<p style="text-align: justify;">Dalam pengembangan sebuah web based program terkadang ada kalanya kita membuat &#8216;bridge&#8217; atau sebuah jembatan yang mengubungkan 2 system atau 2 aplikasi pada 2 server terpisah. Tak jarang tidak hanya bertukar data yang bersifat text tetapi juga bertukar data binary seperti halnya pengiriman gambar atau file-file lain dari satu system ke system yang lain yang berbeda atau bahkan sampai server yang berbeda.</p>
<p><span id="more-3764"></span></p>
<p style="text-align: justify;">Pada keadaan Normal mungkin ada beberapa jalan keluar seperti Web service, xml-rpc etc. Tetapi untuk data yang simple ga perlu kita buat hal yang terlalu rumit.</p>
<p style="text-align: justify;">PHP memiliki sebuah extensi yaitu CURL, banyak sekali fungsi dari CURL ini mulai dari cross server file copy(upload image dengan URL seperti di imageshack.us, sampai men-submit POST data dari satu server ke server lain seperti halnya ada virtual Form yang disubmit).</p>
<p style="text-align: justify;">Untuk melakukan hal ini, kemarin gw membuat sebuah class simple untuk melakukannya. Class ini dapat digunakan untuk menge-post plain text data seperti biasa atau bahkan mengupload binary data file seperti halnya mengupload file dalam form.</p>
<p style="text-align: justify;">Class File-nya dan juga contohnya bisa didownload <a title="Download Virtue Class" href="http://download.rizkhey.net/view.php?file=script/VirtuePost.zip">disini</a></p>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3764&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2010/12/3764-uploading-sending-post-data-via-curl-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Your Own TinyMCE Image Uploader</title>
		<link>http://neo.rizkhey.net/2010/10/3724-make-your-own-tinymce-image-uploader</link>
		<comments>http://neo.rizkhey.net/2010/10/3724-make-your-own-tinymce-image-uploader#comments</comments>
		<pubDate>Sun, 10 Oct 2010 14:22:21 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tinyMCE]]></category>
		<category><![CDATA[TinyMCE Plugin]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3724</guid>
		<description><![CDATA[
Tiny MCE adalah sebuah script opensource untuk WYSIWYG editor, sangat baik untuk membuat sebuah editor content. Well salah satunya mungkin adalah WordPress sampai beberapa software Enterprise juga menggunakannya(Beberapa yang terkenal bisa dilihat disini).
Intinya kemarin beberapa waktu lalu, gw utak atik ni script. Agak sulit buat gw menemukan image uploader yang tepat untuk TinyMCe ini. Akhirnya [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://neo.rizkhey.net/wp-content/uploads/2010/10/pic.jpg"><img class="aligncenter size-medium wp-image-3725" title="Make Image Upload Yourself For TinyMCE" src="http://neo.rizkhey.net/wp-content/uploads/2010/10/pic-449x336.jpg" alt="Make Image Upload Yourself For TinyMCE" width="449" height="336" /></a></p>
<p style="text-align: justify;">Tiny MCE adalah sebuah script opensource untuk WYSIWYG editor, sangat baik untuk membuat sebuah editor content. Well salah satunya mungkin adalah WordPress sampai beberapa software Enterprise juga menggunakannya(Beberapa yang terkenal bisa dilihat <a href="http://tinymce.moxiecode.com/using.php" target="_blank">disini</a>).</p>
<p style="text-align: justify;">Intinya kemarin beberapa waktu lalu, gw utak atik ni script. Agak sulit buat gw menemukan image uploader yang tepat untuk TinyMCe ini. Akhirnya dengan melihat-lihat referensi dari beberapa plugin yang ada, gw akhirnya menemukan caranya. Well it&#8217;s up tou you untuk pengembangannya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> .</p>
<p><span id="more-3724"></span></p>
<p style="text-align: justify;">Well let&#8217;s see, Pertama-tama gw menggunakan resource dari Wiki-nya Penyedia TinyMCE(<a href="http://wiki.moxiecode.com/index.php/TinyMCE:Creating_Plugin">disini</a>). Yang perlu diperhatikan Plugin TinyMCE ada di dalam folder plugin. buatlah sebuah folder baru yang mewakili nama pluginnya. Contoh disini gw menggunakan &#8220;<strong>imagesbrowser</strong>&#8220;.<strong> </strong>Kemudian di dalamnya harus diisi beberapa file dan folder. Kurang lebih:</p>
<blockquote><p><strong>Plugin directory structure</strong></p>
<p>/css<br />
Plugin specific CSS files</p>
<p>/docs<br />
Plugin specific documentation</p>
<p>/images<br />
Plugin specific images</p>
<p>/jscripts<br />
Plugin specific jscripts for HTML dialogs</p>
<p>/langs<br />
Plugin specific language files</p>
<p>/editor_plugin.js<br />
Editor plugin file (compressed) gets loaded when tiny_mce.js is used.</p>
<p>/editor_plugin_src.js<br />
Editor plugin file (source) gets loaded when tiny_mce_src.js or tiny_mce_dev.js is used.</p>
<p>/somedialog.htm<br />
Plugin specific dialog HTML file.</p></blockquote>
<p style="text-align: justify;">Sebelum memulai, untuk mempermudah tutorial ini gw menggunakan sebuah komponen yaitu <strong>phpThumb</strong>(extract di folder pluginnya saja <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> ) untuk membuat preview di dialog window uploadnya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> (Bisa didownload <a href="http://phpthumb.sourceforge.net/" target="_blank">disini</a> atau yang menggunakan PHP 5.3 membutuhkan bugfixnya <a href="http://sourceforge.net/tracker/?func=detail&#038;aid=2991128&#038;group_id=106407&#038;atid=643974" target="_blank">disini</a> download dan extract ke directory yang sama dengan phpThumb berada).</p>
<p style="text-align: justify;">Ok sekarang kita buat filenya satu per satu. Pertama kita buat JS untuk di load oleh si TinyMCE.</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">﻿<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Load plugin specific language pack</span><br />
&nbsp; &nbsp; tinymce.<span style="color: #660066;">PluginManager</span>.<span style="color: #660066;">requireLangPack</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; tinymce.<span style="color: #660066;">create</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tinymce.plugins.imagesbrowser'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Initializes the plugin, this will be executed after the plugin has been created.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This call is done before the editor instance has finished it's initialization so use the onInit event<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* of the editor instance to intercept that event.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {string} url Absolute URL to where the plugin is located.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; init <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ed<span style="color: #339933;">,</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.<span style="color: #660066;">addCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mceaddimagesbrowser'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.<span style="color: #660066;">windowManager</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; file <span style="color: #339933;">:</span> url<span style="color: #339933;">+</span><span style="color: #3366CC;">'/ImageUpload.php'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width <span style="color: #339933;">:</span> <span style="color: #CC0000;">600</span> <span style="color: #339933;">+</span> ed.<span style="color: #660066;">getLang</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser.delta_width'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height <span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span> <span style="color: #339933;">+</span> ed.<span style="color: #660066;">getLang</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser.delta_height'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inline <span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plugin_url <span style="color: #339933;">:</span> url<span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// Plugin absolute URL</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; some_custom_arg <span style="color: #339933;">:</span> <span style="color: #3366CC;">'custom arg'</span> <span style="color: #006600; font-style: italic;">// Custom argument</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Register example button</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.<span style="color: #660066;">addButton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title <span style="color: #339933;">:</span> <span style="color: #3366CC;">'imagesbrowser.imagesbrowser_button_desc'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd <span style="color: #339933;">:</span> <span style="color: #3366CC;">'mceaddimagesbrowser'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; image <span style="color: #339933;">:</span> url <span style="color: #339933;">+</span> <span style="color: #3366CC;">'/img/imagesbrowser.png'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Add a node change handler, selects the button in the UI when a image is selected</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ed.<span style="color: #660066;">onNodeChange</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ed<span style="color: #339933;">,</span> cm<span style="color: #339933;">,</span> n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cm.<span style="color: #660066;">setActive</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser'</span><span style="color: #339933;">,</span> n.<span style="color: #660066;">nodeName</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'IMG'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Creates control instances based in the incomming name. This method is normally not<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* but you sometimes need to create more complex controls like listboxes, split buttons etc then this<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* method can be used to create those.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {String} n Name of the control to create.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return {tinymce.ui.Control} New control instance or null if no control was created.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; createControl <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">,</span> cm<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Returns information about the plugin as a name/value array.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The current keys are longname, author, authorurl, infourl and version.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return {Object} Name/value array containing information about the plugin.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; getInfo <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; longname <span style="color: #339933;">:</span> <span style="color: #3366CC;">'imagesbrowser plugin'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; author <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Rizky Gunawan'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; authorurl <span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://www.rizkhey.net'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; infourl <span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://neo.rizkhey.net/2010/10/3724-make-your-own-tinymce-image-uploader'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; version <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Register plugin</span><br />
&nbsp; &nbsp; tinymce.<span style="color: #660066;">PluginManager</span>.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'imagesbrowser'</span><span style="color: #339933;">,</span> tinymce.<span style="color: #660066;">plugins</span>.<span style="color: #660066;">imagesbrowser</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Save dengan nama &#8220;editor_plugin_src.js&#8221;. Kemudian buatlah Copyan file tsb dengan nama &#8220;editor_plugin.js&#8221; yang isinya hasil kompressan Javascript(Bisa menggunakan yang online <a href="http://javascriptcompressor.com/" target="_blank">disini </a>contohnya).</p>
<p>Kemudian kita buat Javascript lainnya untuk panduan bahasa.</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// UK lang variables</span><br />
tinyMCE.<span style="color: #660066;">addI18n</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'en.imagesbrowser'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span><br />
imagesbrowser_desc <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Insert Image&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_title <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Insert image&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_langaugepicker <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Choose Image&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_pagecode <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Paste your code here&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_button_desc<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Image Manager&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_nogutter <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;No Gutter&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_collapse <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Collapes&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_nocontrols <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;No Controls&quot;</span><span style="color: #339933;">,</span><br />
imagesbrowser_showcolumns <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Show Columns&quot;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>simpan di folder &#8220;<strong>langs</strong>&#8221; dengan nama &#8220;<strong>en.js</strong>&#8221;</p>
<p>Javascript di atas akan meload page bernama  &#8220;<strong>ImageUpload.php</strong>&#8221; di dalam folder plugin tsb. Maka buatlah file tsb(ImageUpload.php) di dalam folder plugin yang kita buat(nanti kita isi, skrg kita lanjut dulu ke tempat lain <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> ).</p>
<p>Kemudian langka kedua kita buat file Javascript untuk melakukan action (membuat tag img untuk diinsert di editor TinyMCE). Kita membuatnya dalam folder &#8220;<strong>js</strong>&#8220;. Contoh saja gw kasih nama &#8220;<strong>imagesInsert</strong>.<strong>js</strong>&#8220;. Isinya kurang lebih:</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">function</span> &nbsp;send_to_editor_onclick<span style="color: #009900;">&#40;</span>theID<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
code <span style="color: #339933;">=</span> getTheCode<span style="color: #009900;">&#40;</span>theID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
tinyMCEPopup.<span style="color: #660066;">execCommand</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mceInsertContent'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> &nbsp;getTheCode<span style="color: #009900;">&#40;</span>theID<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> imageFolderURL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;http://localhost/tinyMCEPluginTutorial/upload/&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> fileName <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hdnFileName&quot;</span><span style="color: #339933;">+</span>theID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> imgTittle <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hdnImgTittle&quot;</span><span style="color: #339933;">+</span>theID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>imageFolderURL<span style="color: #339933;">+</span>fileName<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> alt=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>imgTittle<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> title=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>imgTittle<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> Exit_Button_onclick<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; tinyMCEPopup.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p style="text-align: justify;">Ok, Javascript di atas yang nanti bertugas mengirim hasil gambar ke editor. Sekarang kita buat Halaman file Upload-nya. Simple saja berformat php(karena gw bisanya PHP, apabila Anda bisa programing lain, well just try by your own <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /> it&#8217;s very basic Upload after all <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /> )</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'dbConfig.php'</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;html&gt;<br />
&nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;Images Upload Tutorial&lt;/title&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;js/imagesInsert.js&quot;&gt;&lt;/script&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;../../tiny_mce_popup.js&quot;&gt;&lt;/script&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;../../utils/mctabs.js&quot;&gt;&lt;/script&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;../../utils/form_utils.js&quot;&gt;&lt;/script&gt;<br />
<br />
&nbsp; &nbsp; &lt;/head&gt;<br />
&nbsp; &nbsp; &lt;body&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;table &nbsp;align=&quot;center&quot; width=&quot;450&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td align=&quot;left&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- The FORM START HERE --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fieldset style=&quot;width:450px;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;legend&gt;Message&lt;/legend&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/fieldset&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span style="color: #990000;">unset</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; id=&quot;UploadForm&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;table&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;Choose File&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input type=&quot;file&quot; name=&quot;userFile&quot; /&gt;&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;File Alt/Title&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input name=&quot;txtAlt&quot; type=&quot;text&quot; /&gt;&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td colspan=&quot;2&quot; align=&quot;center&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;submit&quot; name=&quot;btnGo&quot; id=&quot;btnGo&quot; value=&quot;Upload&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;button&quot; name=&quot;btnGo&quot; id=&quot;btnGo&quot; value=&quot;Close&quot; onclick=&quot;Exit_Button_onclick();&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- The FORM END HERE --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Image List --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sqlQuery</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; SELECT<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `ImagesID`,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `FileName`,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `Title`<br />
&nbsp; &nbsp; &nbsp; &nbsp; FROM<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; imgtable<br />
&nbsp; &nbsp; &nbsp; &nbsp; &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sqlQuery</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sqlQuery</span><span style="color: #009900;">&#41;</span>or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sqlQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div align=&quot;center&quot;&gt;No Data&lt;/div&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;table width=&quot;450&quot; align=&quot;center&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Preview&lt;/th&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;FileName&lt;/th&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Title&lt;/th&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Control&lt;/th&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_array"><span style="color: #990000;">mysql_fetch_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sqlQuery</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;img src=&quot;phpThumb/phpThumb.php?src=../../../../upload/<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'FileName'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&amp;w=150&quot; /&gt;&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'FileName'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!--<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Buat Link untuk menginsertnya ke editor. Saat link di klik akan menjalankan fungsi Javascript &quot;send_to_editor_onclick&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yang ada di dalam file &quot;js/imagesInsert.js&quot; disertai ID image-nya untuk nantinya mengakses 2 hiddden field untuk mengambil<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; detail untuk image yang akan diinsert<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&lt;a href=&quot;javascript:void(0);&quot; onclick=&quot;send_to_editor_onclick(<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>);&quot;&gt;Send To Editor&lt;/a&gt;]<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Link untuk menghapus gambar --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&lt;a href=&quot;DeleteImage.php?id=<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Delete Image&lt;/a&gt;]<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Some Element the JS need to take the image to editor --&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input id=&quot;hdnFileName<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;hdnFileName<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'FileName'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input id=&quot;hdnImgTittle<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; name=&quot;hdnImgTittle<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ImagesID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &lt;/body&gt;<br />
&lt;/html&gt;</div></div>
<p style="text-align: justify;">
Ups, gw lupa untuk file Config Databasenya. Database disini digunakan untuk menyimpan data gambar yang diupload nantinya.
</p>
<p>Buatlah sebuah database kemudian buatlah table dengan SQL berikut:</p>
<div class="codecolorer-container sql vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`TinyMCEUploadTutorial`</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">`imgTable`</span> <span style="color: #66cc66;">&#40;</span><br />
<span style="color: #ff0000;">`ImagesID`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">255</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">UNSIGNED</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`FileName`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">255</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #66cc66;">,</span><br />
<span style="color: #ff0000;">`Title`</span> TEXT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE <span style="color: #66cc66;">=</span> MYISAM ;</div></div>
<p>Kemudian buatlah config filenya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'YOUR_db_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TinyMCEUploadTutorial'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Masukan path dimana akan menyimpan file upload-annya, gw misalkan gw melakukannya di root site</span><br />
<span style="color: #000088;">$folderSavePath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'J:\xampp\htdocs\tinyMCEPluginTutorial\upload'</span><span style="color: #339933;">;</span><br />
<br />
<br />
<span style="color: #666666; font-style: italic;">//Just Little Helper, don't mind it</span><br />
<span style="color: #000000; font-weight: bold;">function</span> getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_pop"><span style="color: #990000;">array_pop</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Simpan dengan nama &#8220;<strong>dbConfig.php</strong>&#8221;</p>
<p>Ok, kemudian kita butuh buat file untuk menghandle Upload-nya</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/* <br />
&nbsp;* Upload Process<br />
&nbsp;*/</span><br />
<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'dbConfig.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$userFile</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/htmlentities"><span style="color: #990000;">htmlentities</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'txtAlt'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
<br />
<span style="color: #000088;">$fileName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userFile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'jpg'</span> <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'gif'</span> <span style="color: #339933;">&amp;&amp;</span><br />
&nbsp; &nbsp; getFileExtension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'png'</span> <span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//File type not allowed, just redirect to main mage without doing anything</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'File Type not Allowed'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$currentTempPath</span> &nbsp; &nbsp;<span style="color: #339933;">=</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userFile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$resultPath</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">=</span> <span style="color: #000088;">$folderSavePath</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userFile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultPath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Overwrite warning....<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'File Already Exist, please rename and re upload the file'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/move_uploaded_file"><span style="color: #990000;">move_uploaded_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$currentTempPath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$resultPath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$sqlStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;<br />
&nbsp; &nbsp; INSERT INTO<br />
&nbsp; &nbsp; &nbsp; &nbsp; imgtable<br />
&nbsp; &nbsp; SET<br />
&nbsp; &nbsp; &nbsp; &nbsp; FileName &nbsp; &nbsp;= '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userFile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;',<br />
&nbsp; &nbsp; &nbsp; &nbsp; Title &nbsp; &nbsp; &nbsp; = '&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$userFile</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'<br />
&nbsp; &nbsp; &quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sqlStr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'MySQL Error: '</span><span style="color: #339933;">.</span><a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Image Uploaded'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p style="text-align: justify;">
Simpan dengan nama &#8220;<strong>upload.php</strong>&#8221; Ok Sampai disini sebenarnya sudah selesai pembuatannya <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> Tapi well mungkin kita harus buat sebuah handler untuk penghapusan file <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> Ok kita buat filenya(Ini sebuah contoh, nantinya bisa disatukan dengan handler upload sesuai dengan selera Anda <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> ).
</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'dbConfig.php'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
&nbsp;* Ambil ID gambar yang akan dihapus<br />
&nbsp;*/</span><br />
<span style="color: #000088;">$imageID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT `FileName` FROM imgtable WHERE `ImagesID`='<span style="color: #006699; font-weight: bold;">$imageID</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp;* Image tidak ditemukan<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'File Not Found'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">else</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_array"><span style="color: #990000;">mysql_fetch_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$filePath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folderSavePath</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">.</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'FileName'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filePath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/unlink"><span style="color: #990000;">unlink</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filePath</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;DELETE FROM imgtable WHERE `ImagesID`='<span style="color: #006699; font-weight: bold;">$imageID</span>'&quot;</span><span style="color: #009900;">&#41;</span>or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'File Deleted'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'failed on deleting file: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$filePath</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'File Not Found'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Location: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_REFERER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Ok That&#8217;s all folk <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> Tambahkan di inisialisasi TinyMCE nama Plugin yang baru kita buat ini <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div class="codecolorer-container html4strict vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xmlns:spry<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ns.adobe.com/spry&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>TinyMCE - Upload Image Plugin Tutorial<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
<span style="color: #808080; font-style: italic;">&lt;!-- Some Script Include --&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tiny_mce/tiny_mce.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span><br />
tinyMCE.init({<br />
&nbsp; &nbsp; // General options<br />
&nbsp; &nbsp; mode : &quot;exact&quot;,<br />
&nbsp; &nbsp; elements : &quot;txtContent&quot;,<br />
&nbsp; &nbsp; theme : &quot;advanced&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; relative_urls : &quot;false&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; plugins : &quot;imagesbrowser,inlinepopups&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; // add these two lines for absolute urls<br />
&nbsp; &nbsp; &nbsp; &nbsp; remove_script_host : false,<br />
&nbsp; &nbsp; &nbsp; &nbsp; convert_urls : false,<br />
&nbsp; &nbsp; &nbsp; &nbsp; // General options<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_buttons1 : &quot;bold,italic,underline,strikethrough,imagesbrowser,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselect&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; extended_valid_elements: &quot;textarea[name|class|cols|rows]&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; remove_linebreaks : false,<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_toolbar_location : &quot;top&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_toolbar_align : &quot;left&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_statusbar_location : &quot;bottom&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_resizing : true,<br />
&nbsp; &nbsp; &nbsp; &nbsp; theme_advanced_resizing_max_width : 1000,<br />
&nbsp; &nbsp; &nbsp; &nbsp; content_css : &quot;css/tinyMCE.css&quot;,<br />
&nbsp; &nbsp; &nbsp; &nbsp; width &nbsp; &nbsp; &nbsp; : 1000,<br />
&nbsp; &nbsp; &nbsp; &nbsp; height &nbsp; &nbsp; &nbsp; : 500<br />
});<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtContent&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000; font-weight: bold;">textarea</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></div>
<div id="attachment_3733" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/10/Capture.jpg"><img src="http://neo.rizkhey.net/wp-content/uploads/2010/10/Capture-450x367.jpg" alt="The Result" title="The Result" width="450" height="367" class="size-medium wp-image-3733" /></a><p class="wp-caption-text">The Result</p></div>
<p style="text-align: justify;">Well Kurang lebih ini adalah salah satu cara membuat sebuah plugin sendiri untuk TinyMCE. Pada dasarnya tutorial ini very basic. Gw belum memberi paging untuk menampilkan daftar gambar yang pernah diupload, dan belum membuat resize atau juga pembuatan thumbnail. Anda bisa melakukan modifikasi sendiri <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: justify;">Sebelum selesai, gw memberikan file komplitnya. Pertama gw pack lengkap dengan TinyMCE 3.3.8 yang lainnya hanya contoh pluginnya saja. Perhatikan Anda tetap perlu membuat SQL databse untuk table-nya dapat dilihat di atas atau dalam file &#8220;dbConfig.php&#8221; gw tuliskan struktur tablenya</p>
<table align="center" width="350">
<tr>
<td align="center">
<a href="http://download.rizkhey.net/view.php?file=script/tinyMCEPluginTutorial.zip">Full Pacakge</a>(1,28 MB)
</td>
<td align="center"><a href="http://download.rizkhey.net/view.php?file=script/imagesbrowser.zip">Plugin Only</a>(178,1 KB)</td>
</tr>
<tr>
<td colspan="2" align="left">Termasuk didalamnya PHPThumb yang sudah dipach untuk PHP 5.3 Tested on PHP 5.3(XAMPP 1.7.2 for Windows)</td>
</tr>
</table>
<p>Plugin ini dibuat dari dasar memodifikasi dari plugin <a href="http://weblogs.asp.net/nawaf/archive/2008/04/10/syntaxhighlighter-plug-in-for-tinymce-3-x-wysiwyg-editor.aspx" target="_blank">SyntaxHighlighter Plug-in for Tinymce 3.X WYSIWYG Editor </a>.</p>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3724&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2010/10/3724-make-your-own-tinymce-image-uploader/feed</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Live Checking With AJAX &amp; jQUERY</title>
		<link>http://neo.rizkhey.net/2010/08/3707-live-checking-with-ajax-jquery</link>
		<comments>http://neo.rizkhey.net/2010/08/3707-live-checking-with-ajax-jquery#comments</comments>
		<pubDate>Mon, 30 Aug 2010 10:26:14 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[live checking]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3707</guid>
		<description><![CDATA[
Beberapa tahun yang lalu(  ) gw menuliskan tutroial membuat live checking dengan AJAX, Well waktu itu gw lagi ngebut dengan belajar dasar beberapa bahasa baru, sehingga belum begitu mengerti beberapa framework Javascript seperti jQuery, mootols, etc.
Sekitar setahun kemudian(sekarang  ) gw mulai banyak berkecimpung dalam dunia scripting selain juga dalam server side programing dengan [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" title="Live Checking With AJAX &amp; jQUERY" src="http://neo.rizkhey.net/wp-content/uploads/2009/08/ajax.gif" alt="Live Checking With AJAX &amp; jQUERY" width="450" height="332" /></p>
<p style="text-align: justify;">Beberapa tahun yang lalu( <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> ) gw menuliskan tutroial membuat <a title="LiVE checking with AJAX" href="http://neo.rizkhey.net/2009/08/2947-live-checking-with-ajax" target="_blank">live checking dengan AJAX</a>, Well waktu itu gw lagi ngebut dengan belajar dasar beberapa bahasa baru, sehingga belum begitu mengerti beberapa framework Javascript seperti jQuery, mootols, etc.</p>
<p style="text-align: justify;">Sekitar setahun kemudian(sekarang <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> ) gw mulai banyak berkecimpung dalam dunia scripting selain juga dalam server side programing dengan PHP. Dan mulailah mempelajari sedikit demi sedikit tentang javascript framework.</p>
<p><span id="more-3707"></span></p>
<p style="text-align: justify;">Dari kesekian banyak, gw memilih jQuery untuk dipelajari dan diterapkan di project keseharian gw. Kenapa? entah, I just like it <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> .</p>
<p style="text-align: justify;">Setelah sekitar 1 tahun, mungkin gw pengen memperbaharui tutorial gw yang dulu, dan mencoba memperlihatkan semudah apa sih AJAX dengan jQuery. Coba mari kita bandingkan.</p>
<p style="text-align: justify;">Gw menggunakan beberapa file dari tutorial sebelumnya, seperti config file, checker file hanya ada sedikit yang di rubah.</p>
<p style="text-align: justify;"><a href="http://www.rizkhey.net/try/TestAJAX/index-jquery.php">DEMO</a></p>
<p><iframe width="480" height="450" frameborder="0" src="http://www.rizkhey.net/try/TestAJAX/index-jquery.php"></iframe></p>
<p>Langkah Buatnya:</p>
<p><strong>Pertama</strong>: Buat Table dengan spesifikasi sbb:</p>
<div class="codecolorer-container sql vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="sql codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">`ajax_demo`</span> <span style="color: #66cc66;">&#40;</span><br />
&nbsp; <span style="color: #ff0000;">`id`</span> <span style="color: #993333; font-weight: bold;">INT</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span><br />
&nbsp; <span style="color: #ff0000;">`value`</span> <span style="color: #993333; font-weight: bold;">VARCHAR</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">23</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span><br />
&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> &nbsp;<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM &nbsp;<span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET<span style="color: #66cc66;">=</span>latin1 <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">10</span> ;<br />
<br />
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">`ajax_demo`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">`value`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'aku'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'kamu'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'dia'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'saya'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'anda'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'kami'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'you'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span><br />
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">'we'</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p><strong>Kedua</strong>, buat file &#8220;config.php&#8221;</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/*<br />
Just connecting to DB... or use your config File ^_^<br />
*/</span><br />
<a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[YOUR_DB_HOST]&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[YOUR_DB_USERNAME]&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;[YOUR_DB_PASSWORD]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;[DBNAME]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p><strong>Ketiga</strong>, Buat file utamanya:</p>
<div class="codecolorer-container html4strict vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;">include<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;config.php&quot;</span><span style="color: #66cc66;">&#41;</span>;</span><br />
<span style="color: #009900;">?&gt;</span><br />
<span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">meta</span></a> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span>AJAX jQuery -DEMO-<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">title</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a> <span style="color: #000066;">language</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript&quot;</span>&gt;</span><br />
&nbsp; &nbsp; $().ready(function()<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set Focus on load agar langsung texbox terfokus<br />
&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; $('#txtValue').focus(); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Triger untuk OnBlur pada jQuery Dapat diganti dengan beberapa cara lain,<br />
&nbsp; &nbsp; &nbsp; &nbsp; Untuk lebih jelasnya lihat dokumentasi jQuery:<br />
&nbsp; &nbsp; &nbsp; &nbsp; http://api.jquery.com/category/events/<br />
&nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; $('#txtValue').blur(function(){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Mengganti SPAN kosong menjadi gif untuk loading<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#imgTry').html(&quot;<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'6nr0un50.gif'</span> <span style="color: #66cc66;">/</span>&gt;</span> Checking!!&quot;); <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Proses AJAX<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.ajax<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ({<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: 'POST', &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Cara mengesend Data, ada POST atau GET */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: &quot;checker.php&quot;, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Target/ file tujuan untuk mengeksekusi*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: &quot;value=&quot;+$('#txtValue').val(),/* Query String/Data yang akan dikirimkan*/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: function(data) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Apabila sukses lakukan perintah berikut */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(data=='OK')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Apabila yang direturn adalah string 'OK'(read file &quot;checker.php&quot;) */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ganti String pada span ber ID 'imgTry' yang sebelumnya berisi gambar loading menjadi string <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#imgTry').html('<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;arrived.jpg&quot;</span>&gt;</span> OK, value belum digunakan!!!');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Apabila yang direturn selain string 'OK'(read file &quot;checker.php&quot;) */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Ganti String pada span ber ID 'imgTry' yang sebelumnya berisi gambar loading menjadi string <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; */<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#imgTry').html('<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">img</span></a> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unArrived.jpg&quot;</span>&gt;</span> Value sudah ada!!!');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }); <br />
&nbsp; &nbsp; &nbsp; &nbsp; })<br />
&nbsp; &nbsp; });<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">script</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span><br />
<br />
body,td,th {<br />
&nbsp; &nbsp; font-family: Lucida Sans Unicode, Lucida Grande, sans-serif;<br />
&nbsp; &nbsp; font-size: 12px;<br />
&nbsp; &nbsp; color: #333;<br />
}<br />
td {<br />
&nbsp; &nbsp; border: 1px solid #999;<br />
}<br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/style.html"><span style="color: #000000; font-weight: bold;">style</span></a>&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">head</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span>Data yang bisa digunakan:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;">$query&nbsp; <span style="color: #66cc66;">=</span> mysql_query<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;SELECT * FROM ajax_demo&quot;</span><span style="color: #66cc66;">&#41;</span>or die<span style="color: #66cc66;">&#40;</span>mysql_error<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</span><br />
<span style="color: #009900;">?&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;134&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellspacing</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellpadding</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;30&quot;</span>&gt;</span>No<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;358&quot;</span>&gt;</span>Value<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;">while<span style="color: #66cc66;">&#40;</span>$result <span style="color: #66cc66;">=</span> mysql_fetch_row<span style="color: #66cc66;">&#40;</span>$query<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></span><br />
<span style="color: #009900;"><span style="color: #66cc66;">&#123;</span></span><br />
<span style="color: #009900;">?&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;?php echo $result<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;&lt;?php echo $result<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;?php</span><br />
<span style="color: #009900;"><span style="color: #66cc66;">&#125;</span></span><br />
<span style="color: #009900;">?&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span>Ketikan Kata yang Diinginkan, Apabila Kata yang ada di ketikan ada di dalam kolom value di atas, maka akan muncul pesan error<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span>Ketikan kata, kemudian tekan Tab untuk mengeksekusinya <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form1&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form1&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;post&quot;</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;452&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellspacing</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">cellpadding</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;107&quot;</span>&gt;</span>On Blur<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;333&quot;</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">input</span></a> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtValue&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;txtValue&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> <span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;imgTry&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/span.html"><span style="color: #000000; font-weight: bold;">span</span></a>&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">label</span></a>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/td.html"><span style="color: #000000; font-weight: bold;">td</span></a>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/tr.html"><span style="color: #000000; font-weight: bold;">tr</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/table.html"><span style="color: #000000; font-weight: bold;">table</span></a>&gt;</span><br />
<br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/form.html"><span style="color: #000000; font-weight: bold;">form</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/p.html"><span style="color: #000000; font-weight: bold;">p</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">body</span></a>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">html</span></a>&gt;</span></div></div>
<p><strong>Keempat</strong>, Buat file Checkernya(&#8216;checker.php&#8217;). file ini yang tugasnya mengexecute dan mengecek ke database saat AJAX calling di execute.</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #666666; font-style: italic;">/*<br />
Checker File...<br />
Digunakan untuk konek ke DB mengecek dan mengembalikan ke Javascript <br />
untuk ditampilkan di HTML secara live tanpa reloading<br />
*/</span><br />
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;config.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_REQUEST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$q</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM ajax_demo WHERE value='<span style="color: #006699; font-weight: bold;">$value</span>'&quot;</span><span style="color: #009900;">&#41;</span>or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$sum</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$q</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Untuk mencari berapa jumlah record dari hasil Query</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sum</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Value belum ada</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;OK&quot;</span><span style="color: #339933;">;</span>&nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">else</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Value sudah ada</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;NO&quot;</span><span style="color: #339933;">;</span>&nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//---------- Finish... hanya seperti ini ---------------</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Okay&#8230; That&#8217;s All untuk file-filenya. </p>
<p>Mari kita telaah sedikit demi sedikit. </p>
<p>Mari kita lihat pada header di file utama terdapat javascript di bagian headernya kurang lebih:</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; Set Focus on load agar langsung texbox terfokus<br />
&nbsp; &nbsp; &nbsp; &nbsp; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;img src='6nr0un50.gif' /&gt; Checking!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Proses AJAX dimulai</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ajax</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;checker.php&quot;</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;value=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>data<span style="color: #339933;">==</span><span style="color: #3366CC;">'OK'</span><span style="color: #009900;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;arrived.jpg&quot;&gt; OK, value belum digunakan!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;unArrived.jpg&quot;&gt; Value sudah ada!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>baris awal dimulai dengan syntax:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$().ready(function(){<br />
<br />
/*<br />
All code here<br />
*/<br />
<br />
});</div></div>
<p>Maksudnya adalah lakukan  semua code pada saat halaman sudah terload seluruhnya.</p>
<p>Pada perintah pertama pada fungsi ready function:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$('#txtValue').focus();</div></div>
<p>Maksudnya kita mengeset kursor pada textbox ber id &#8220;txtValue&#8221; pada saat halaman selesai di load. Gunakan tanda kress untuk memilih &#8220;id&#8221; dari element HTML.</p>
<p>Berikutnya adalah tempat dimana AJAX akan di execute saat textbox kehilangan focus/blur. Pada jQuery tidak lagi dibutuhkan penambahan atribut &#8220;onBlur&#8221; pada element. tetapi dapat langsung dilakukan pada header halaman/include script.</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$('#txtValue').blur(function(){<br />
&nbsp;// Do Something here<br />
});</div></div>
<p>Di atas dapat diartikan pada saat textbox ber-ID &#8216;txtValue&#8217; kehilangan fokus, lakukan fungsi/perintah yang sudah ditentukan pada bagian &#8220;// Do Something here&#8221;.</p>
<p>Untuk menggunakan AjAX, kita tinggal panggil satu fungsi dari object jQUERY, cara pakainya simple seperti berikut ini:</p>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$.<span style="color: #660066;">ajax</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;checker.php&quot;</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;value=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>data<span style="color: #339933;">==</span><span style="color: #3366CC;">'OK'</span><span style="color: #009900;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;arrived.jpg&quot;&gt; OK, value belum digunakan!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;unArrived.jpg&quot;&gt; Value sudah ada!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>
<strong>Untuk:</strong></p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">type: 'POST'</div></div>
<p>Menggunakan type method pengiriman data POST, selain POST ada juga cara pengiriman data secara &#8220;GET&#8221;
</p>
<p>
<strong>Untuk:</strong></p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">url: &quot;checker.php&quot;</div></div>
<p>URL kemana data akan dikirim/di proses
</p>
<p>
<strong>Untuk:</strong></p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">data: &quot;value=&quot;+$('#txtValue').val()</div></div>
<p>Mengirimkan data yang akan di kirim dalam bentuk Query String. <em>Gunakan method &#8220;val()&#8221; untuk memperoleh  value dari sebuah element</em>.
</p>
<p>
<strong>Untuk:</strong></p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">success: function(data) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(data=='OK')&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#imgTry').html('&lt;img src=&quot;arrived.jpg&quot;&gt; OK, value belum digunakan!!!');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('#imgTry').html('&lt;img src=&quot;unArrived.jpg&quot;&gt; Value sudah ada!!!');<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div></div>
</p>
<p>Proses yang dilakukan saat AJAX berhasil</p>
<p>Kurang lebih begitulah pemanggilan AJAX dengan jQuery, mari coba kita bandingkan dengan koding javascript manual <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<h3>Manual:</h3>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> xmlhttp<span style="color: #339933;">;</span><br />
<br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> Checker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> theValue <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;txtValue&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Ambil value dari &quot;id&quot; textbox(Yang dilihat id bukan name-nya)</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>theValue<span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlhttp<span style="color: #339933;">=</span>GetXmlHttpObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xmlhttp<span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span> <span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Browser does not support HTTP Request&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;imgTry&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;img src='6nr0un50.gif' /&gt; Checking!!&quot;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> url<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;checker.php&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">=</span>url<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;?value=&quot;</span><span style="color: #339933;">+</span>theValue<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlhttp.<span style="color: #660066;">onreadystatechange</span><span style="color: #339933;">=</span>stateChanged<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlhttp.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span>url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xmlhttp.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> stateChanged<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>xmlhttp.<span style="color: #660066;">readyState</span><span style="color: #339933;">==</span><span style="color: #CC0000;">4</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>xmlhttp.<span style="color: #660066;">responseText</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;OK&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;imgTry&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;img src='arrived.jpg'&gt; OK, value belum digunakan!!!&quot;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;imgTry&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&lt;img src='unArrived.jpg'&gt; Value sudah ada!!!&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<br />
<br />
<span style="color: #003366; font-weight: bold;">function</span> GetXmlHttpObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// code for IE7+, Firefox, Chrome, Opera, Safari</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// code for IE6, IE5</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<h3>jQuery</h3>
<div class="codecolorer-container javascript vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;img src='6nr0un50.gif' /&gt; Checking!!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Proses AJAX dimulai</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ajax</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;checker.php&quot;</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;value=&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#txtValue'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>data<span style="color: #339933;">==</span><span style="color: #3366CC;">'OK'</span><span style="color: #009900;">&#41;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;arrived.jpg&quot;&gt; OK, value belum digunakan!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#imgTry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;unArrived.jpg&quot;&gt; Value sudah ada!!!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p style="text-align: justify;">Apabila dilihat di atas, coding manual yang pertama gw menggunakan proses GET, karena kalau menggunakan proses POST lebih panjang lagi Codingnya.
<p style="text-align: justify;">Untuk yang kedua menggunakan jQuery jauh lebih simple. Walau mungkin beberapa beginner Javascript akan menemukan sesuatu yang unik dalam codingnya yang berbasis OOP javascript. Tetapi well gw pikir memang sebuah awall membutuhkan waktu untuk pembiasaan. </p>
<p style="text-align: justify;">Pada awalnya gw juga agak asing. Bagaimana bisa dalam sebuah method terdapat function(misal pada &#8220;$(&#8216;#txtValue&#8217;).blur(function(){ /*isi fungsi*/ });&#8221;), dan  bahkan dalam function tersebut bisa ada function lagi(ajax pada Success). Dan masih banyak kalau mau mendalami lebih lanjut <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' />  </p>
<p>Akhirnya semoga membantu, dan silahkan dinikmati full code-nya, dapat di <a href="http://download.rizkhey.net/view.php?file=script/TestAJAX-jQuery.zip">download disini</a> <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /></p>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3707&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2010/08/3707-live-checking-with-ajax-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache 2.2, PHP5, dan Mysql di Windows Based PC</title>
		<link>http://neo.rizkhey.net/2010/07/3655-installing-apache-2-2-php5-dan-mysql-di-windows-based-pc</link>
		<comments>http://neo.rizkhey.net/2010/07/3655-installing-apache-2-2-php5-dan-mysql-di-windows-based-pc#comments</comments>
		<pubDate>Sat, 24 Jul 2010 00:04:51 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mySQl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3655</guid>
		<description><![CDATA[
Seminggu sudah rasanya kesibukan semakin membara di kehiduapn gw, makin sedikit waktu untuk sekedar menuliskan sesuatu di Blog, ini.
Kurang lebih setelah project di kantor selesai tahap produksinya, gw kepikiran untuk menanamkan aplikasi gw di system yang pure tanpa menggunakan LAMP program untuk server PHP-nya. Tetapi pengalaman gw menginstal PHP tanpa menggunakan LAMP program itu hanya [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a rel="lightbox" href="http://my.rizkhey.net/files/325801.JPG" target="_blank"><img class="aligncenter" style="border: 0pt none;" src="http://my.rizkhey.net/files/ext_thumb_325801.JPG" border="0" alt="" width="450" height="384" /></a></p>
<p style="text-align: justify;">Seminggu sudah rasanya kesibukan semakin membara di kehiduapn gw, makin sedikit waktu untuk sekedar menuliskan sesuatu di Blog, ini.</p>
<p style="text-align: justify;">Kurang lebih setelah project di kantor selesai tahap produksinya, gw kepikiran untuk menanamkan aplikasi gw di system yang pure tanpa menggunakan LAMP program untuk server PHP-nya. Tetapi pengalaman gw menginstal PHP tanpa menggunakan LAMP program itu hanya terjadi waktu gw masih semester 2 waktu kuliah. Waktu itu kalau ga salah masih menggunakan PHP3 <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<p style="text-align: justify;">Beberapa kali gw mencoba menginstallnya ada saja yang ga jalan. Mulai dari Apachenya ga mau baca PHP, sampai extensi tidak terbaca oleh si PHP. Kalau ada yang membaca tutorial gw tentang cara <a title="How To: installing Apache2, Mysql, dan PHP5 di Ubuntu(9.10)" href="http://neo.rizkhey.net/2010/02/3381-how-to-installing-apache2-mysql-dan-php5-di-ubuntu9-10">menginstall PHP dan mempersiapkan lingkungan kerjanya </a>di Linux beberapa waktu lalu, gw bisa bilang menginstall PHP di Linux itu jauh lebih mudah daripada menginstallnya di Windows(paling tidak di Linux kita sudah tinggal kipas2 dan biarkan si system yang mengupdate konfigurasinya), Bisa dibilang semudah menggunakan LAMP(kebalikannya, gw ga berhasil menginstall XAMPP di LINUX&#8230; really <em>pain in the ass</em> <img src='http://neo.rizkhey.net/smilies/yahoo_laughloud.gif' alt='&#58;&#41;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;&#41;' /> just think that I&#8217;am stupid enough <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> ).</p>
<p style="text-align: justify;">Setelah satu hari an ini berkutat, akhirnya gw menemukan caranya, memang kalau ada niat pasti bisa. Nah gw mau mencoba menjabarkan cara-caranya disini. Siapa tahu ada yang membutuhkannya.</p>
<p><span id="more-3655"></span></p>
<p style="text-align: justify;">Tutorial ini gw buat menggunakan bahan-bahan berikut ini:</p>
<ol style="text-align: justify;">
<li>httpd-2.2.15-win32-x86-no_ssl.msi (Apache 2.2.15 no SSL installer for Windows)</li>
<li>php-5.2.14-Win32.zip (Manual Install Source dalam ZIP safe thread)*</li>
<li>mysql-essential-5.1.49-winx64.msi (Simple aja mysql-nya soalnya yang full package besar banged <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /> )</li>
<li>phpMyAdmin-3.3.4-english.zip (Aplikasi basis PHP paling simple buat mengatur mysql <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> )</li>
</ol>
<blockquote>
<p style="text-align: justify;">* Gunakan PHP yang dicompile dengan Visual C versi 6 untuk penggunaan pada Apache, untuk penggunaan dengan IIS, gunakan PHp yang dicompile dengan VC9.</p>
</blockquote>
<p style="text-align: justify;">
<p style="text-align: justify;">Dan tutorial ini dimasak dengan alat yaitu operating system(ditest pada):</p>
<ol style="text-align: justify;">
<li>Windows Server 2008 Enterprise R2 64 bit</li>
<li>Windows 7 Ultimate 64 bit</li>
</ol>
<p style="text-align: justify;">Tools yang dibutuhkan(Optional dan terserah selera):</p>
<ol style="text-align: justify;">
<li>Notepad++ (untuk mengedit config file atau kalau tahan silahkan gunakan notepad biasa)</li>
<li>winzip/winrar/7zip/etc etc untuk nge-unzip walau biasanya kalau ekstensi .zip build in Windows sudah bisa membukanya.</li>
</ol>
<p style="text-align: justify;">Okey Kita mulai saja&#8230;</p>
<p style="text-align: justify;">
<p style="text-align: justify;">Tutorial ini membahas bagaimana sih caranya menginstall PHP 5.2(yang masih umum, walau 5.3 tidak jauh berbeda dengan 5.2 cara menginstallnya) pada APACHE 2.2 series yang biasanya sudah dipaketkan dengan dalam program-program LAMP seperti XAMPP. Well simply I just want to know &#8230; <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<p style="text-align: justify;">Okey kita mulai&#8230; <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<p style="text-align: justify;">Langkah pertama pastikan bahan dan alat-alat sudah disiapkan <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /> Kemudian gw sarankan untuk mematikan UAC terlebih dahulu agar tidak terjadi hal-hal yang tidak diinginkan <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> .</p>
<p style="text-align: justify;">Okey kita mulai dengan:</p>
<h3 style="text-align: justify;">Menginstall Apache 2.2</h3>
<p style="text-align: justify;">Apache adalah salah satu teman baik sebagai HTTP server yang banyak digunakan dan biasanya selalu nempel dengan PHP. Hubungannya apa dengan PHP. Anggaplah file PHP dipanggil oleh apache dan kemudian apache membutuhkan PHP interpreternya supaya bisa diproses.</p>
<p style="text-align: justify;">Oke kita mulai menginstall Apache.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/325801.JPG" target="_blank"><img style="border: 0pt none;" title="Awal menginstall Apache 2.2" src="http://my.rizkhey.net/files/ext_thumb_325801.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Awal menginstall Apache 2.2</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/325902.JPG" target="_blank"><img style="border: 0pt none;" title="Apache akan menanyakan identitas server" src="http://my.rizkhey.net/files/ext_thumb_325902.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Apache akan menanyakan identitas server, isilah sebutuhnya saja</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326003.JPG" target="_blank"><img style="border: 0pt none;" title="Ga usah Ribet, pilih Typical saja" src="http://my.rizkhey.net/files/ext_thumb_326003.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Ga usah Ribet, pilih Typical saja</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326104.JPG" target="_blank"><img style="border: 0pt none;" title="Well karena gw ga suka kepanjangan pathnya, sehingga gw buat lebih ringkas, Up to you juga mau ditaruh mana" src="http://my.rizkhey.net/files/ext_thumb_326104.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Well karena gw ga suka kepanjangan pathnya, sehingga gw buat lebih ringkas, Up to you juga mau ditaruh mana, hanya gw contohkan disitu saja yah...</p></div>
<p style="text-align: justify;">Lalu lanjutkan saja sampai installasi selesai.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326205.JPG" target="_blank"><img style="border: 0pt none;" title="Installasi selesai, Folder tempat APAche muncul di hardisk" src="http://my.rizkhey.net/files/ext_thumb_326205.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Installasi selesai, Folder tempat APAche muncul di hardisk</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326407.JPG" target="_blank"><img style="border: 0pt none;" title="Buka Browser untuk mengetestnya, ketik alamat http://localhost Apabila mendapatkan layar seperti di atas, maka Anda telah sukses menginstall Apache" src="http://my.rizkhey.net/files/ext_thumb_326407.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Buka Browser untuk mengetestnya, ketik alamat http://localhost Apabila mendapatkan layar seperti di atas, maka Anda telah sukses menginstall Apache</p></div>
<p style="text-align: justify;">
<h3 style="text-align: justify;">Installasi PHP 5</h3>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326306.JPG" target="_blank"><img style="border: 0pt none;" title="Extract 'php-5.2.14-Win32.zip' ke dalam folder yang mudah di akses, gw contohkan di folder 'PHP5'" src="http://my.rizkhey.net/files/ext_thumb_326306.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Extract &#39;php-5.2.14-Win32.zip&#39; ke dalam folder yang mudah di akses, gw contohkan di folder &#39;PHP5&#39;</p></div>
<p style="text-align: justify;">Sebenarnya ga bisa di bilang  installasi karena langkahnya hanya extract saja <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></p>
<p style="text-align: justify;">Tapi sebelum lanjut, perhatikan ada file bernama &#8220;php.ini-recommended&#8221; rename atau buat copyannya kemudian rename menjadi &#8220;php.ini&#8221;. Nantinya file ini akan menjadi file config PHP.</p>
<h3 style="text-align: justify;">Penyatuan PHP dan APACHE</h3>
<p style="text-align: justify;">Kini buka file <strong>httpd.conf</strong> yang ada di dalam folder <strong>apache 2.2</strong> dalam folder <strong>conf</strong>. Kemudian ada sedikit banyak yang harus ditambahkan <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326508.JPG" target="_blank"><img style="border: 0pt none;" title="Tambahkan &quot;LoadModule php5_module &quot;c:/PHP5/php5apache2_2.dll&quot; &quot; pada baris terakhir load module Sesuaikan dengan PATH tempat mengextract PHP-nya" src="http://my.rizkhey.net/files/ext_thumb_326508.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Tambahkan &quot;LoadModule php5_module &quot;c:/PHP5/php5apache2_2.dll&quot; &quot; pada baris terakhir load module Sesuaikan dengan PATH tempat mengextract PHP-nya</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326609.JPG" target="_blank"><img style="border: 0pt none;" title="Kini kita atur dimana file PHP yang nantinya dieksekusi. Secara default yang digunakan adalah folder htdocs dalam folder apache" src="http://my.rizkhey.net/files/ext_thumb_326609.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Kini kita atur dimana file PHP yang nantinya dieksekusi. Secara default yang digunakan adalah folder htdocs dalam folder apache.  PAda contoh di atas, gw mencoba menaruhnya dalam folder lain. Tidak harus dalam 1 drive bisa ada di partisi/drive lain juga <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327215.JPG" target="_blank"><img style="border: 0pt none;" title="Kita tambahkan mime type handler untuk PHP. Pada Tag &quot;&lt;IfModule mime_module&gt;&quot;, tambahkan  &quot;AddType application/x-httpd-php .php&quot; sebelum tag penutup" src="http://my.rizkhey.net/files/ext_thumb_327215.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Kita tambahkan mime type handler untuk PHP. Pada Tag &quot;&quot;, tambahkan  &quot;AddType application/x-httpd-php .php&quot; sebelum tag penutup</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327316.JPG" target="_blank"><img style="border: 0pt none;" title="Kita harus juga menambahkan Directory indexnya. Ubah menjadi : &quot;DirectoryIndex index.php index.html&quot; Tanpa menambahkan &quot;index.php&quot;, maka nantinya halaman tanpa index.html walau ada index,php hanya akan menampilkan list isi directory saja" src="http://my.rizkhey.net/files/ext_thumb_327316.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Kita harus juga menambahkan Directory indexnya. Ubah menjadi : &quot;DirectoryIndex index.php index.html&quot; Tanpa menambahkan &quot;index.php&quot;, maka nantinya halaman tanpa index.html walau ada index.php hanya akan menampilkan list isi directory saja</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326710.JPG" target="_blank"><img style="border: 0pt none;" title="Last One, tambahkan 1 line bertuliskan &quot;PHPIniDir &quot;c:/PHP5&quot; &quot; di paling bawah yang digunakan untuk meload konfigurasi  dari PHP nantinya" src="http://my.rizkhey.net/files/ext_thumb_326710.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Last One, tambahkan 1 line bertuliskan &quot;PHPIniDir &quot;c:/PHP5&quot; &quot; di paling bawah yang digunakan untuk meload konfigurasi  dari PHP nantinya</p></div>
<p>Okay, sekarang konfigurasi untuk menyatukan PHP dan Apache 2.2 selesai. Kini kita bisa coba merestart apache server untuk mengetahui apakah berhasil atau tidak.</p>
<p>Merestart Apache sangat mudah, cukup klik icon Apache di dekat jam dan pilih restart. Apabila muncul seperti gambar berikut:</p>
<p style="text-align: center;"><a rel="lightbox" href="http://my.rizkhey.net/files/326811.JPG" target="_blank"><img class="aligncenter" style="border: 0pt none;" src="http://my.rizkhey.net/files/ext_thumb_326811.JPG" border="0" alt="" width="450" height="384" /></a></p>
<p>Dan Waktu mencoba melihat log error malah blank dan ga ada petunjuk, mungkin begini caranya kita bisa coba. Buka command prompt ikuti langka berikut(sesuaikan nama directorynya):</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/326912.JPG" target="_blank"><img style="border: 0pt none;" title="Melalui konsol, Error msg akan terlihat" src="http://my.rizkhey.net/files/ext_thumb_326912.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Melalui konsol, Error msg akan terlihat</p></div>
<p>Kalau munculnya pesan error seperti itu tandanya Anda salah pakai versi PHP, kalau menurut pesan tersebut, Anda menggunakan versi non-safe. Coba gunakan thread save version <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' />. Hapus semua isi folder PHP di extract kemudian extract yang baru(yang thread safe).</p>
<p>Sebelum merestart(kalau sudha ya gpp, nanti bisa direstart lagi), lakukan langkah berikut:</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327013.JPG" target="_blank"><img style="border: 0pt none;" title="Copy file &quot;php5ts.dll&quot; ke folder &quot;bin&quot; dalam apache folder" src="http://my.rizkhey.net/files/ext_thumb_327013.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Copy file &quot;php5ts.dll&quot; ke folder &quot;bin&quot; dalam apache folder</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327114.JPG" target="_blank"><img style="border: 0pt none;" title="Kemudian restart Apachenya" src="http://my.rizkhey.net/files/ext_thumb_327114.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Kemudian restart Apachenya</p></div>
<p>Setelah start dengan sukses, mari kita coba hasilnya. Buka file kosong dan ketikan perintah php_info seperti gambar di bawah dan kemudian simpan dalam folder htdocs yang tadi kita arahkan sebagai directori source php yang akan dicompile oleh PHP.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327417.JPG" target="_blank"><img style="border: 0pt none;" title="Kita buat test file" src="http://my.rizkhey.net/files/ext_thumb_327417.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Kita buat test file</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327518.JPG" target="_blank"><img style="border: 0pt none;" title="Yup hasilnya sukses" src="http://my.rizkhey.net/files/ext_thumb_327518.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Apabila hasilnya begini, selamat Anda sudah sukses menginstall PHP dan Apache</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327619.JPG" target="_blank"><img style="border: 0pt none;" title="Setelah hubungan PHP-APACHE selesai, Saatnya kita oprek sedikit settingan PHp agar sesuai dengan kebutuhan" src="http://my.rizkhey.net/files/ext_thumb_327619.JPG" border="0" alt="" width="450" height="384" /></a><p class="wp-caption-text">Setelah hubungan PHP-APACHE selesai, Saatnya kita oprek sedikit settingan PHp agar sesuai dengan kebutuhan. Buka file php.ini dalam folder PHP</p></div>
<p>Beberapa settingan di gw yang gw rubah agar sesuai dengan kebutuhan gw yaitu:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">short_open_tag = On<br />
<br />
post_max_size = 8M<br />
<br />
extension_dir = &quot;C:/PHP5/ext&quot;</div></div>
<p style="text-align: justify;">Beberapa alasan:</p>
<ul>
<li style="text-align: justify;"><strong>Short Open tag</strong>, kebanyakan programer cukup malas mengetikan full open tag &#8220;&lt;?php&#8221; dan lebih suka menggunakan short open tag. Apabila opsi ini off, maka semua open tag menggunakan short open tag tidak akan di compile oleh PHP malah akan ditampilkan mentah-mentah di layar.</li>
<li style="text-align: justify;"><strong>post_max_size</strong>, Ini berhubungan dengan max upload size. Apabila max upload size sampe 100MB, tetapi max postnya cuma 8MB, sama aja kita cuma bisa upload sebesar 8MB.</li>
<li style="text-align: justify;"><strong>extension_dir</strong>, tempat extension PHP, masukan pathnya disini.</li>
</ul>
<p>Kemudian kalau di scroll ke bawah sedikit, kita akan menemukan berderet extension PHP yang masih dicomment. Kalian bisa Uncomment semua kalau mau atau pilih sebutuhnya saja. Biasa sih mungkin kalo gw begini:</p>
<div class="wp-caption aligncenter" style="width: 385px"><a rel="lightbox" href="http://my.rizkhey.net/files/327720.JPG" target="_blank"><img style="border: 0pt none;" title="Pilih sesuai kebutuhan, lihat dokumentasi di php.net untuk lebih jelasnya" src="http://my.rizkhey.net/files/ext_thumb_327720.JPG" border="0" alt="" width="375" height="450" /></a><p class="wp-caption-text">Pilih sesuai kebutuhan, lihat dokumentasi di php.net untuk lebih jelasnya</p></div>
<p>Simpan dan kemudian restart APACHE. Dan mari kita lihat, seharusnya extension yang kita uncomment akan muncul di php info. Tapi&#8230;</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327821.JPG" target="_blank"><img style="border: 0pt none;" title="Mysql function tidak ditemukan walau sudah di uncomment" src="http://my.rizkhey.net/files/ext_thumb_327821.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Mysql function tidak ditemukan walau sudah di uncomment</p></div>
<p style="text-align: justify;">lalu kenapa? ada yang salah?</p>
<p style="text-align: justify;">tenang&#8230; problem ini juga yang membuat gw pusing setengah mati setiap kali check dan richek apakah pathnya salah atau tidak. Ternyata semua path benar.</p>
<p style="text-align: justify;">Setelah membaca dari berbagai sumber, akhirnya gw menemukan kenapa. Yaitu mysql membutuhkan dll lain. Setelah membaca petunjuknya <a href="http://www.php.net/manual/en/install.windows.extensions.php">disini</a>, Akhirnya gw mencoba menaruh file-file yang dibutuhkan tersebut ke dalam folder <strong>system</strong> dalam folder <strong>windows</strong>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/327922.JPG" target="_blank"><img style="border: 0pt none;" title="File ini dicopy" src="http://my.rizkhey.net/files/ext_thumb_327922.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">File ini dicopy ke folder System Windows</p></div>
<p style="text-align: justify;">Singkatnya, karena gw mencoba di windows 64bit, gw menaruhnya di &#8220;C:\Windows\SysWOW64&#8243;.</p>
<p style="text-align: center;"><a rel="lightbox" href="http://my.rizkhey.net/files/328023.JPG" target="_blank"><img class="aligncenter" style="border: 0pt none;" src="http://my.rizkhey.net/files/ext_thumb_328023.JPG" border="0" alt="" width="450" height="393" /></a></p>
<p style="text-align: justify;">Setelah gw restart Apachenya hasilnya pun kelihatan, mysql muncul di daftar dalam php info.</p>
<p style="text-align: center;"><a rel="lightbox" href="http://my.rizkhey.net/files/328124.JPG" target="_blank"><img class="aligncenter" style="border: 0pt none;" src="http://my.rizkhey.net/files/ext_thumb_328124.JPG" border="0" alt="" width="450" height="393" /></a></p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328225.JPG" target="_blank"><img style="border: 0pt none;" title="Ngetest Koneksi Database ke Mysql " src="http://my.rizkhey.net/files/ext_thumb_328225.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Ngetest Koneksi Database ke Mysql </p></div>
<h3>Menginstall MySQL 5.1</h3>
<p>Menginstall Mysql jauh lebih mudah ketimbang 2 langkah sebelumnya yang harus ngublek-ngublek settingan.</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328326.JPG" target="_blank"><img style="border: 0pt none;" title="Pilih yang detailed saja" src="http://my.rizkhey.net/files/ext_thumb_328326.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Pilih yang detailed saja</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328427.JPG" target="_blank"><img style="border: 0pt none;" title="Pilih sesuai kebutuhan karena ini untuk developer, well gw pilih yang atas" src="http://my.rizkhey.net/files/ext_thumb_328427.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Pilih sesuai kebutuhan karena ini untuk developer, well gw pilih yang atas</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328528.JPG" target="_blank"><img style="border: 0pt none;" title="Well Multipurpose kalau gw pake dalam developer karena tidak pasti juga... aplikasi macam2 :)" src="http://my.rizkhey.net/files/ext_thumb_328528.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Well Multipurpose kalau gw pake dalam developer karena tidak pasti juga... aplikasi macam2 <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328629.JPG" target="_blank"><img style="border: 0pt none;" title="Untuk jenis banyaknya koneksi karena bukan untuk umum tentunya, gw pilih yang paling sedikit :)" src="http://my.rizkhey.net/files/ext_thumb_328629.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Untuk jenis banyaknya koneksi karena bukan untuk umum tentunya, gw pilih yang paling sedikit <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328730.JPG" target="_blank"><img style="border: 0pt none;" title="Untuk Anda yang berencana menggunakan huruf2 selain latin, lebih baik mungkin pilih yang kedua" src="http://my.rizkhey.net/files/ext_thumb_328730.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Untuk Anda yang berencana menggunakan huruf2 selain latin, lebih baik mungkin pilih yang kedua</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328831.JPG" target="_blank"><img style="border: 0pt none;" title="Install Service supaya langsung startup pada saat Widows start, jangan lupa checklist pilihan di bawahnya agar mudah diakses dari command line" src="http://my.rizkhey.net/files/ext_thumb_328831.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Install Service supaya langsung startup pada saat Widows start, jangan lupa checklist pilihan di bawahnya agar mudah diakses dari command line</p></div>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/328932.JPG" target="_blank"><img style="border: 0pt none;" title="Masukan PAssword untuk root Anda disini" src="http://my.rizkhey.net/files/ext_thumb_328932.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">Masukan PAssword untuk root Anda disini</p></div>
<p style="text-align: justify;">Setelah beres, kita bisa test mysql-nya. Caranya buka commandline. Kemudian ketikan perintah &#8220;<strong>mysql -uroot -p</strong>&#8221; kemudian tekan enter apabila dia menanyakan password masukan password. APabila berhasil masuk maka bisa dibilang penginstallan mysql berhasil.</p>
<p style="text-align: justify;">Kemudian untuk penginstallan PHPmyadmin, cukup unpack dan taruh di htdocs yang ditentukan sebelumnya. Kemudian renamse saja nama foldernya supaya ga ribet menjadi &#8220;phpmyadmin&#8221; contohnya.</p>
<p style="text-align: justify;">Buka dalam folder rename file &#8220;config.sample.inc.php&#8221; menjadi &#8220;<strong>config.inc.php</strong>&#8220;</p>
<p style="text-align: justify;">buka dan isikan string blowfishnya, supaya si phpmyadmin ga rewel lagi <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' />.</p>
<p style="text-align: justify;">Kemudian coba akses dari browser dengan alamat yang ditentukan:</p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/329134.JPG" target="_blank"><img style="border: 0pt none;" title="PHPmyadmin sukses dibuka" src="http://my.rizkhey.net/files/ext_thumb_329134.JPG" border="0" alt="" width="450" height="393" /></a><p class="wp-caption-text">PHPmyadmin sukses dibuka</p></div>
<p>Coba login dengan user root dan password yang kita input sewaktu menginstall mysql tadi. Apabila berhasil masuk maka&#8230; Selamat Anda berhasil menginstall APache 2.2, PHP 5, dan mySQL dengan selamat <img src='http://neo.rizkhey.net/smilies/yahoo_smiley.gif' alt='&#58;&#41;' class='wp-smiley' width='18' height='18' title='&#58;&#41;' /></p>
<div class="wp-caption aligncenter" style="width: 460px"><a rel="lightbox" href="http://my.rizkhey.net/files/3292345.JPG" target="_blank"><img style="border: 0pt none;" title="PHPMyAdmin Sukses " src="http://my.rizkhey.net/files/ext_thumb_3292345.JPG" border="0" alt="" width="450" height="376" /></a><p class="wp-caption-text">PHPMyAdmin Sukses </p></div>
<p>Oke sekian dari gw pagi ini, semoga bermanfaat&#8230; bener kan kata gw&#8230; lebih gampang di Linux ga sepanjang ini <img src='http://neo.rizkhey.net/smilies/yahoo_tongue.gif' alt='&#58;&#80;' class='wp-smiley' width='18' height='18' title='&#58;&#80;' /></p>
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<p style="text-align: justify;">
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3655&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2010/07/3655-installing-apache-2-2-php5-dan-mysql-di-windows-based-pc/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Installing Imagemagick extension on Windows(Using XAMPP)</title>
		<link>http://neo.rizkhey.net/2010/06/3588-installing-imagemagick-extension-on-windowsusing-xampp</link>
		<comments>http://neo.rizkhey.net/2010/06/3588-installing-imagemagick-extension-on-windowsusing-xampp#comments</comments>
		<pubDate>Tue, 15 Jun 2010 14:32:14 +0000</pubDate>
		<dc:creator>リズキ</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Imagemagick]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://neo.rizkhey.net/?p=3588</guid>
		<description><![CDATA[
Image Magick adalah sebuah program 3rd party yang tersedia crossplatform untuk Windows dan juga untuk Linux. Imagemagick itu apa? simpelnya adalah seperti halnya photoshop hanya dalam bentuk comand line.
Lalu apa hubungannya dengan PHP?
Karena gw bekerja di salah satu perusahaan media massa, yang didalamnya berisi bejibun file-file data  baik image, pdf, dan berbagai format lainnya, gw [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/imagemagick.jpg"><img class="aligncenter size-medium wp-image-3589" title="imagemagick" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/imagemagick-435x449.jpg" alt="imagemagick" width="435" height="449" /></a></p>
<p style="text-align: justify;">Image Magick adalah sebuah program 3rd party yang tersedia crossplatform untuk Windows dan juga untuk Linux. Imagemagick itu apa? simpelnya adalah seperti halnya photoshop hanya dalam bentuk comand line.</p>
<p style="text-align: justify;">Lalu apa hubungannya dengan PHP?</p>
<p style="text-align: justify;">Karena gw bekerja di salah satu perusahaan media massa, yang didalamnya berisi bejibun file-file data  baik image, pdf, dan berbagai format lainnya, gw menemukan keterbatasan dengan GD Library bawaan PHP. Nah selain GD Lib, salah satu yang cukup populer adalah Imagemagick ini. Kebetulan next project di dalam kantor berhubungan dengan ini.</p>
<p style="text-align: justify;">PHP memiliki penghubung ke imagemagick, walau tanpa extension penghubung tersebut, kita tetap bisa menggunakan imagemagick dengan perintah &#8220;exec(&#8220;&#8221;)&#8221;, atau &#8220;shell_exec()&#8221;, atau &#8220;system&#8221;. tergantung selera(yap hanya saja kalau di Windows platform, mau tidak mau harus menggunakan &#8220;popen&#8221; ketimbang &#8220;exec&#8221; biasa. Tetapi paling tidak, dengan menggunakan extension ini, pekerjaan kita lebih mudah tanpa harus menyentuh consolnya(walau console is still the best <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /> ).</p>
<p style="text-align: justify;">Imagemagick natif-nya adalah Linux, tetapi ada juga binary untuk Windows. Di Linux sendiri, menginstallnya sangatlah simple, cukup dengan perintah apt-get install kita bisa menginstall imagemagick, dan juga kemudian kita install extensi php-nya dan saat itu juga konfigurasi php langsung terupdate dan kita tinggal restart apache dan beres. Imagemagick siap dipakai.</p>
<p><span id="more-3588"></span></p>
<p style="text-align: justify;">Tetapi tidak under Windows, it&#8217;s really pain in the ass&#8230;</p>
<p style="text-align: justify;">Di Windows, kalau kita asal install ahsilnya entah DLL tidak terload atau malah apache crash. Nah usut punya usut, gw menemukan caranya. Lumayan buat tambahan mainan.</p>
<blockquote>
<p style="text-align: justify;">reference:</p>
<ul>
<li><a href="http://www.elxsy.com/2009/07/installing-imagemagick-on-windows-and-using-with-php-imagick/" target="_blank">Installing ImageMagick on Windows and Using with PHP &amp; Imagick</a></li>
<li><a href="http://thinktibits.blogspot.com/2008/09/installing-imagemagick-on-windows-setup.html" target="_blank">Installing ImageMagick on Windows &#8212; Setup Imagick on PHP </a></li>
</ul>
</blockquote>
<p style="text-align: justify;">Gw mencobanya di 2 system berbasis windows dengan 2 versi XAMPP berbeda, yaitu WIndows server 2008 R2(XAMPP versi 1.6.8 dengan PHP 5.2.6) dan Windows 7 (XAMPP versi 1.7.2 dengan PHP 5.3).</p>
<blockquote><p>Cara ini bekerja di XAMPP 1.7.2 tetapi di 1.73, gw mendapatkan apache selalu crash&#8230;. <img src='http://neo.rizkhey.net/smilies/yahoo_sad.gif' alt='&#58;&#40;' class='wp-smiley' width='18' height='18' title='&#58;&#40;' /> </p></blockquote>
<div id="attachment_3590" class="wp-caption aligncenter" style="width: 347px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im01.jpg"><img class="size-medium wp-image-3590" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im01-337x450.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="337" height="450" /></a><p class="wp-caption-text">XAMPP 1.6.8(PHP 5.2.6 on Win Server 2008 R2 - atas)XAMPP 1.7.2(PHP 5.3 on Win 7 - bawah)</p></div>
<p style="text-align: center;">
<p style="text-align: justify;">Berikut cara-caranya:</p>
<ol>
<li>Pertama Download dahulu Installer Imagemagick <a href="http://www.imagemagick.org/script/binary-releases.php#windows" target="_blank">disini</a>. Download yang: ImageMagick-x.x.x-x-Q16-windows-dll.exe. Gw kurang mengerti perbedaannya, tetapi katanya ada something funny dengan versi staticnya. Entah apa itu. Di Tutorial ini gw menggunakan versi yang udah agak berumur, yaitu: &#8220;ImageMagick-6.6.2-1-Q16-windows-dll.exe&#8221;.</li>
<li>Untuk Safety, stop semua XAMPP process(apache terutama). Apabila UAC aktif, jalankan setup dengan menggunakan administrator right. Ada beberapa hal yang perlu diperhatikan. Yaitu:
<div id="attachment_3591" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im02.jpg"><img class="size-medium wp-image-3591" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im02-450x348.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="450" height="348" /></a><p class="wp-caption-text">Ubah default Path ke &quot;C:imagemagick&quot;Jangan ke tempat default seperti &quot;C:Program Files....&quot;</p></div>
<div id="attachment_3592" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im03.jpg"><img class="size-medium wp-image-3592" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im03-450x348.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="450" height="348" /></a><p class="wp-caption-text">Pastikan opsi kedua dari ata terchecklist</p></div>
<p>Selain itu bisa diabaikan, dan kemudian lanjutkan installasi sampai selesai.<br />
Setelah Selesai, coba buka command line(cmd.exe), kemudian ketikan perintah &#8220;convert&#8221; kemudian tekan enter. Apabila berhasil, maka windows command line akan menampilkan seabreg dokumentasi cara penggunaan Imagemagick</p>
<p><div id="attachment_3598" class="wp-caption aligncenter" style="width: 403px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im09.jpg"><img class="size-medium wp-image-3598" title="perintah 'convert' dijalankan di Command Line" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im09-393x450.jpg" alt="perintah 'convert' dijalankan di Command Line" width="393" height="450" /></a><p class="wp-caption-text">Perintah &#39;convert&#39; dijalankan di Command Line</p></div></li>
<li style="text-align: justify;">Langkah berikutnya adalah kita menyeting APACHE dan juga PHP-nya. Tapi sebelumnya, kita butuh library untuk PHP-nya untuk dapat menghubungkan PHP dengan Imagemagick. Ada satu hal yang perlu diperhatikan yaitu bahwa PHP yang berjalan di APACHE server(dalam hal ini termasuk XAMPP, WAMP dll) dicompile dengan menggunakan compiler Ms. Visual C versi 6, sedangkan apabila berjalan di IIS dicompile dengan menggunakan Ms. Visual C versi 9.<br />
Perbedaan ini berlaku sampai dengan peng-compile-an extension library-nya. Maka dari itu, untuk menjalankan Imagemagick dari PHP yang dijalankan pada XAMPP, kita butuh extension library yang dicompile dengan Visual C versi 6.<br />
Dan lagi-lagi butuh diingat PHP 5.2.x dan 5.3 tidak bisa menggunakan library/file yang sama.<br />
Untuk PHP 5.2.x bisa di download di <a href="http://valokuva.org/outside-blog-content/imagick-windows-builds/080709/php_imagick_dyn-Q16.dll">sini</a> (Semenjak kita menggunakan versi Dinamic, download yang php_imagick_dyn-Q16.dll, rename menjadi &#8220;php_imagick&#8221; agar lebih mudah digunakan).<br />
Untuk PHP 5.3 bisa di download di <a href="http://www.sk89q.com/2010/03/vc6-windows-binaries-for-imagick-2-3-0/">sini</a> (Pilih yang TS &#8211; Thread Save).<br />
Setelah di download, Copy ke folder extension php. Biasanya di:</p>
<blockquote><p>&lt;xamppFolder&gt;\php\ext\</p></blockquote>
<div id="attachment_3593" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im04.jpg"><img class="size-medium wp-image-3593" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im04-450x339.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="450" height="339" /></a><p class="wp-caption-text">Copy ke Folder extension PHP</p></div>
<p>Setelah itu, Edit &#8220;php.ini&#8221;. Untuk PHP 5.2 biasanya berada di <strong>&#8220;apache\bin\php.ini</strong>&#8221; kalau di PHP 5.3 biasanya berada di &#8220;<strong>php\php.ini</strong>&#8220;. Buka dan tambahkanjikalau tidak ada line untuk me-load dll yang baru saja kita copy:</p>
<pre>extension=php_imagick.dll</pre>
<div id="attachment_3595" class="wp-caption aligncenter" style="width: 426px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im06.jpg"><img class="size-full wp-image-3595" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im06.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="416" height="262" /></a><p class="wp-caption-text">Tambahkan line tsb apabila tidak ada, atau uncomment jika dicomment</p></div>
<p>Setelah itu save dan tutup file.</li>
<li style="text-align: justify;">Langkah terakhir adalah menambahkan path di apache.conf untuk memberitahu dimana letak si Imagemagick berada. Buka http.conf(di &lt;xamppfolder&gt;\apache\conf\httpd.conf), kemudian tambahkan satu line berisikan tulisan:
<pre>SetEnv MAGICK_HOME “C:/imagemagick</pre>
<p><div id="attachment_3594" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im05.jpg"><img class="size-medium wp-image-3594" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im05-450x336.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="450" height="336" /></a><p class="wp-caption-text">Tambahkan satu line di akhir file: &quot;SetEnv MAGICK_HOME “C:/imagemagick&quot;</p></div></li>
<li style="text-align: justify;">Kemudian Save dan tutup File. restart XAMPP, apabila tidak ada error, kita bisa pastikan bahwa imagemagick berhasil diinstall di phpinfo():
<p><div id="attachment_3596" class="wp-caption aligncenter" style="width: 459px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im07.jpg"><img class="size-medium wp-image-3596" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im07-449x251.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="449" height="251" /></a><p class="wp-caption-text">Imagemagick Installed</p></div></li>
<li style="text-align: justify;">Mari kita coba jalankan sebuah script sederhana,
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?</span><br />
<span style="color: #000088;">$im</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> imagick<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'a.jpg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// resize by 200 width and keep the ratio</span><br />
<span style="color: #000088;">$im</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">thumbnailImage</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">// write to disk</span><br />
<span style="color: #000088;">$im</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">writeImage</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'a_thumbnail.jpg'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>Kalau dilihat, jauh lebih mudah bukan dalam mengcreate sebuah thumbnail daripada menggunakan GD LIb yang harus melalui beberapa tahap <img src='http://neo.rizkhey.net/smilies/yahoo_bigsmile.gif' alt='&#58;&#68;' class='wp-smiley' width='18' height='18' title='&#58;&#68;' /></li>
</ol>
<p style="text-align: justify;">Apabila berhasil dan thumbnail terbuat, maka selamat, Anda berhasil menginstall Imagemagick di Windows dan menyambungkannya ke PHP di XAMPP. Sisanya tinggal bermain-main dengan extension ini.</p>
<p style="text-align: justify;">
<div id="attachment_3597" class="wp-caption aligncenter" style="width: 460px"><a href="http://neo.rizkhey.net/wp-content/uploads/2010/06/im08.jpg"><img class="size-medium wp-image-3597" title="Installing imagemagick extension on windows using XAMPP" src="http://neo.rizkhey.net/wp-content/uploads/2010/06/im08-450x379.jpg" alt="Installing imagemagick extension on windows using XAMPP" width="450" height="379" /></a><p class="wp-caption-text">Contoh Imagemagick untuk membuat pantulan images</p></div>
<img src="http://neo.rizkhey.net/?ak_action=api_record_view&id=3588&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://neo.rizkhey.net/2010/06/3588-installing-imagemagick-extension-on-windowsusing-xampp/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

