Selasa, 31 Maret 2015

The Way to write script CSS & HTML & PHP

PHP script in HTML


<html>
<head>
<title>Sample PHP insert into HTML</title> </head>
<body>
<h1>Hello </h1>

<?php  
echo "Good Night";
//sample PHP comment
?>

<p>I'm learning PHP Now</p>
</body>
</html>


HTML script in PHP


<?php
echo "<html>";    
echo "<head>";    
echo "<title>Contoh PHP disisipkan dalam HTML</title>";   
echo "</head>";
echo "<body>";
echo "<h1>Hello </h1>";
echo "Selamat malam"; //Ini contoh komentar php    
echo "<p align=\"center\">Saya sedang belajar PHP</p>";   
echo "</body>";    
echo "</html>";
?>


Link to external CSS file in PHP


<?php    
echo "<html>";    
echo "<head>";    
echo "<title>Contoh PHP disisipkan dalam HTML</title>";
echo "<link href=\"namafile.css\" rel=\"stylesheet\" type=\"text/css\" />";  
echo "</head>";    
echo "<body>";    
echo "<h1>Hello </h1>";    
echo "Selamat malam"; //Ini contoh komentar php    
echo "<p align=\"center\">I'm learning PHP</p>";    
echo "</body>";    
echo "</html>";
?>

CSS script in PHP


<?php    
echo "<html>";    
echo "<head>";    
echo "<title>Contoh PHP disisipkan dalam HTML</title>";
echo "<style type=\"text/css\">";
echo ".contohcss1 { text-align:center; }";
echo ".contohcss2 { text-align:left; }";
echo "</style>";    

echo "</head>";    
echo "<body>";    
echo "<h1>Helllo </h1>";    
echo "Selamat malam"; //Ini contoh komentar php    
echo "<p align=\"center\">Saya sedang belajar di blog zainalhakim.web.id</p>";    
echo "</body>";    
echo "</html>";
?>

source:http://www.zainalhakim.web.id/posting/cara-menuliskan-css-html-dalam-php.html

Senin, 30 Maret 2015

Sample PHP connect to accdb using ODBC

<?php
$Filename="c:\Users\Setiono\Documents\ptsi.accdb";
$user = "root";
$password = "";
$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=$Filename", $user, $password) or die("gak bisa konek!!!");
$query = "SELECT * FROM Query1";
$rs = odbc_exec($conn,$query);
$cols = odbc_num_fields($rs);
$rows=odbc_num_rows($rs);

echo "<link href=\"nice-table.css\" rel=\"stylesheet\" type=\"text/css\" />";
echo "<table border=1; class=nice-table>";

// tampilkan field name
    for ($i = 1; $i <= $cols; $i++)
    {
        $n[$i] = odbc_field_name($rs, $i);
        echo "<th>", $n[$i], "</th>";
    }

    while (odbc_fetch_array($rs)){
        echo "<tr>";
        for ($x=1; $x <= $cols; $x++) {
            $fld[$x] = odbc_result($rs,$x);
            echo "<td>", $fld[$x], "</td>";
        }
        echo "</tr>";       
    }
echo "</table>";

odbc_close($conn)

Jumat, 27 Maret 2015

Sample PHP Connect to Access 2007 using ADO

<?php

//create an instance of the ADO connection object
$conn = new COM ("ADODB.Connection")
  or die("Cannot start ADO");

//define connection string, specify database driver
$connStr = "PROVIDER=Microsoft.Ace.OLEDB.12.0;Data Source= \\Sample.accdb";
  $conn->open($connStr); //Open the connection to the database

//declare the SQL statement that will query the database
$query = "SELECT * FROM table1";

//execute the SQL statement and return records
$rs = $conn->execute($query);

$num_columns = $rs->Fields->Count();
echo $num_columns . "<br>";

for ($i=0; $i < $num_columns; $i++) {
    $fld[$i] = $rs->Fields($i);
}

echo "<table>";

while (!$rs->EOF)  //carry on looping through while there are records
{
    echo "<tr>";
    for ($i=0; $i < $num_columns; $i++) {
        echo "<td>" . $fld[$i]->value . "</td>";
    }
    echo "</tr>";
    $rs->MoveNext(); //move on to the next record
}


echo "</table>";

//close the connection and recordset objects freeing up resources
$rs->Close();
$conn->Close();

$rs = null;
$conn = null;
?>


source: https://support.winhost.com/kb/a913/how-to-connect-to-access-2007-with-php.aspx

Cara membuat link terbuka di tab baru otomatis

Cara membuat link terbuka di tab baru otomatis
All About Blogspot Templates : Target Blank - adalah code yang berfungsi sebagai perintah agar link yang ketika di clik akan membuka secara otomatis di tab baru.

Ada banyak manfaat fungsi  <target="_blank"> tersebut. Diantaranya, yakni; memperkecil nilai bounce rate, karena visitor banyak meng-klik blog Anda tanpa meninggalkan laman sebelumnya. Sehingga juga berfungsi melangsingkan rangking Alexa.

Dalam hal ini, ada beberapa tips yang bisa dilakukan. 
Pertama : Seluruh link yang ada pada blog akan terbuka di tab baru secara otomatis ketika di clik visitor. Caranya dengan melakukan edit template HTML berikut ini:

1. Masuk dashboard blogger blog Anda,
2. Klik Template => Edit HTML =>
3. Cari kode </head> untuk lebih mempermudah gunakan  CTRL+F.

4. Setelah ketemu kode </head>, masukkan kode dibawah ini tepat diatasnya.
<base target="_blank"/>
5. Save Template.
Kedua : Editing code target blank secara manual. Cara ini hanya memfungsikan salah satu atau beberapa link yang dikehendaki saja yang terbuka secara otomatis pada tab baru. 
 Dari cara kedua ini, dapat dilakukan dengan 2 cara. 

1. Editing link yang berada di halaman postingan. Caranya dapat dilakukan langsung seperti gambar dibawah ini: 
edit link di halaman postingan
Cara membuat link terbuka di tab baru di halaman postingan
2. Menggunakan fungsi code <target="_blank"> 
Cara 2 adalah cara yang agak rumit sedikit ketimbang cara 1. Yaitu dengan menggunakan kode HTML:

Apabila link biasa, maka kodenya seperti ini:

<a href='http://redaksiexpo2012.blogspot.com'>Blogspot Templates</a>
Sedangkan untuk link dengan fungsi menggunakan code perintah <target="_blank"> 
<a href='http://redaksiexpo2012.blogspot.com'target="_blank">Blogspot Templates</a>
Apa yang beda kedua code tersebut?
Yups, di kode HTML buka link baru, ada tambahan kode target="_blank". Tepatnya setelah "http://contohlink.com/".

Jadi, untuk membuat link open new tab, silahkan tambahkan kode target="_blank" tepat setelah kode "http://contohlink.com/".

Walau sedikit rumit, pada cara ke 2 ini kita dapat melakukan edit link tertarget/tertentu. Termasuk link berada didalam widget blog di dalam code HTML. Sedangkan link pada halaman lainnya berfungsi normal.

Demikian Cara membuat link terbuka di tab baru otomatis semoga bermanfaa.

Source: http://redaksiexpo2012.blogspot.com/2013/10/cara-membuat-link-terbuka-di-tab-baru.html

Kamis, 19 Maret 2015

Killing a Windows Service that seems to hang on "Stopping"

It sometimes happens (and it's not a good sign most of the time): you'd like to stop a Windows Service, and when you issue the stop command through the SCM (Service Control Manager) or by using the ServiceProcess classes in the .NET Framework or by other means (net stop, Win32 API), the service remains in the state of "stopping" and never reaches the stopped phase. It's pretty simple to simulate this behavior by creating a Windows Service in C# (or any .NET language whatsoever) and adding an infinite loop in the Stop method. The only way to stop the service is by killing the process then. However, sometimes it's not clear what the process name or ID is (e.g. when you're running a service hosting application that can cope with multiple instances such as SQL Server Notification Services). The way to do it is as follows:
  1. Go to the command-prompt and query the service (e.g. the SMTP service) by using sc:

    sc queryex SMTPSvc
  2. This will give you the following information:

    SERVICE_NAME: SMTPSvc
            TYPE               : 20  WIN32_SHARE_PROCESS
            STATE              : 4  RUNNING
                                    (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
            WIN32_EXIT_CODE    : 0  (0x0)
            SERVICE_EXIT_CODE  : 0  (0x0)
            CHECKPOINT         : 0x0
            WAIT_HINT          : 0x0
            PID                : 388
            FLAGS              :


    or something like this (the "state" will mention stopping).
  3. Over here you can find the process identifier (PID), so it's pretty easy to kill the associated process either by using the task manager or by using taskkill:

    taskkill /PID 388 /F

    where the /F flag is needed to force the process kill (first try without the flag).
Please be careful when you do this; it's useful for emergencies but you shouldn't use it on a regular basis (use it as a last chance to solve the problem or to avoid the need of a reboot in an exceptional situation). It can even be used to stop a service that has the "NOT-STOPPABLE" and/or "IGNORES_SHUTDOWN" flag set (e.g. Terminal Services on a Windows Server 2003 is non-stoppable), at least when it's not hosted in the system process. You can query all this information by means of the sc command.
For real freaks (don't do this on a production machine!): if you want to show the behavior of the "Blaster" worm which caused the RPC service to stop, try to stop the RPC service (but safe your work first :-)). It's pretty simple to do if you have administrative privileges (just a great example of why you should NOT run as a high-privileged user on the system). When you succeed in killing the process (pretty straightforward), you'll see the shutdown countdown popping up (if you've seen Blaster in action in the past, you'll have a deja-vu). You can stop this by typing the command shutdown -a (abort shutdown), as I posted previously in the Blaster-timeframe since this wasn't known very well and it was quite useful to abort the started shutdown in order to apply the patch. You can even restart the service then by using sc again. Notice that if the RPC is stopped, you can't even connect to the MMC console for the Services management (services.msc) since this relies on RPC. So, you really can't start the service again by using the MMC snap-in. The only way to start the service again is by using sc start <servicename>. The output of this (nice but at the same time ugly) demo looks like this (again, don't try this at home; I'm not responsible for any damage or data loss possible):
C:\Documents and Settings\Administrator>sc queryex rpcss
SERVICE_NAME: rpcss
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 2332
        FLAGS              :

C:\Documents and Settings\Administrator>taskkill /pid 2332 /FSUCCESS: The process with PID 2332 has been terminated.

C:\Documents and Settings\Administrator>shutdown /a

C:\Documents and Settings\Administrator>sc start rpcss
SERVICE_NAME: rpcss
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 2  START_PENDING
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x7d0
        PID                : 2520
        FLAGS              :

C:\Documents and Settings\Administrator>sc queryex rpcss
SERVICE_NAME: rpcss
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN))

        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 2520
        FLAGS              :

If you decide to try it (ignoring my warnings), don't rely on the system afterwards since various applications will have suffered from this. I'm experimenting with these things myself only on a Virtual PC with undo disks enabled.
To go short: sc is one of my favorite commands to mess around with services (install, uninstall, etc) and to query for information on services. The sc command can also be used to query all the active drivers on the system. If you don't like system-beeps for example, you can use sc stop Beep to stop the according driver. But please again, be careful when you play with it. Fortunately, disastrous driver stoppings are not possible and will be denied by sc.
More info on sc.exe can be found via http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx.


source: http://community.bartdesmet.net/blogs/bart/archive/2004/10/16/438.aspx