Error: MySQL extension is deprecated & will be removed in the future of PHP (PHP)–Perubahan MySQL kepada MySQLi

2:42 PTG 0 Comments A+ a-


Kebanyakan command mysql  pada tahun 2014 kebelakang adalah:

<?php
$link = mysql_connect('localhost', 'user', 'password');
mysql_select_db('dbname', $link);


Sekarang kena tukar kepada command MySQLsebab dikatakan pada masa akan datang command diatas tidak akan digunakan dah kerana server akan beralih kepada pengkalan data MySQLi.



<?php
$link = mysqli_connect('localhost', 'user', 'password', 'dbname');


Manakala untuk function mysql_result(), perlu ditukar kepada:

function mysqli_result($result, $row, $field = 0) {
// Adjust the result pointer to that specific row
$result->data_seek($row);
// Fetch result array
$data = $result->fetch_array();

return $data[$field];
}

Menggunakan PHP untuk Validation

7:23 PG 0 Comments A+ a-

 

Di dalam web-based programming, ada 2 kaedah untuk validation atau pengesahan data.

1) Client-side validation = Validation ini dilakukan di side client dengan info@data tidak dihantar ke server untuk di sahkan. Sangat cepat dan server friendly namun boleh dibolosi dengan mudah. Itupun jika javascript sudah di enable oleh end-user dan java disupport oleh web-browser.

2) Server-side validation : Pengesahan ini dilaksanakan dari server, data dihantar ke server bila submit button ditekan dan server mengesahkan data tersebut.  Server side validation lebih secure dan reliable kerana kamu tidak boleh menghantar data yang salah atau trick seperti di client-side validation. Semua server side scripting seperti PHP boleh membuat pengesahan.

2 Fungsi Validation

1) Validation asas:  Form periksa semua data sudah dimasukkan, ia melihat satu persatu field dan lepaskan sekiranya semua sudah diisi. Contoh:  Borang daftar Facebook yang mahukan semua maklumat diisi.

2) Data Format Validation:  Pengesahan format data. Contoh jika email perlu tanda @. Dan nama tidak perlu ada nombor atau field number tidak boleh diisi dengan string. Keyword: regular expressions untuk check format validation.

EXAMPLE PHP VALIDATION (BUKAN JAVASCRIPT)

Form biasa

<form action="validate.php" method="POST"> 
Name:<input type="text" name="Name" />
Email:<input type="text" name="Email" />
Number:<input type="text" name="number" />
<input type="submit" name="submit” /> </form>
</body>
</html>


Form ini biasa sahaja, guna fungsi post untuk hantar ke fail validate.php. Validate.php akan sahkan.



validate.php




if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name = $_POST["name"]

$email = $_POST["email"];

$number= $_POST["website"];

}

if (empty($name)){

echo "<p class=\"error\">Your last name cannot be blank</p>";

}

if(empty($email)) )){

echo "<p >Your email id cannot be blank</p>";

}

if(empty($number) || $number <1000000000&& $number>=1000000000)

{

echo “<p>Number should be of 10 digit</p>”

}

Why Windows 9 is Windows 10

12:53 PG 0 Comments A+ a-



Microsoft really, really wants to put some distance between their new OS release and Windows 8. In fact, the company wants to distance itself from 8 so much that it decided to skip a whole version number. There’s not going to be a Windows 9: Microsoft is going straight to 10.

What’s the logic behind going with Windows 10? It’s not as though this is the 10th major Windows build. It’s not even the 10th NT build. Obviously, it’s because of the old good-version-bad-version rhythm. The old joke  was that every other version of Windows was bad. Windows XP was great, Vista was bad. Windows 7 was superb, Windows 8 was bad, and Windows 8.1 was better. Windows 9, clearly, would’ve been utter garbage, so Microsoft went straight to 10 — kind of like how construction workers used to skip the 13th floor when they built skyscrapers.

No, not really — but Microsoft is trying to signal a move in a new direction. That direction is away from products that people fund unintuitive and sometimes infuriating to use, like a touch-first interface on a non-touch computer. Instead, Microsoft is heading towards things that are familiar and make sense on the type of computer you’re using (like an OS that intelligently adapts its interface to your computer’s current configuration), and just work.
When asked about the decision to call it Windows 10, Joe Belfiore replied that “This product, when you see [it in its], fullness I think you’ll agree with us that it’s a more appropriate name.” That fullness applies to Windows Phone, too, which will see Windows 10 as its next major upgrade. Windows 10 is built for “screens from 4 to 80 inches,” according to Belfiore.


That’s nice and clear then, right? Microsoft has cranked the forget-Windows-8-inator up to 10 in order to eradicate any feelings of malice you might have had toward the Windows brand. They’ve crossed the threshold, people, into a bold new era of Windows releases.

MYSQL: Memanggil 2 table dengan menggabungkan guna secondary key

1:33 PG 0 Comments A+ a-



TABLE HR_TETAP
TABLE YIKSYS_JANTINA 


SELECT hr_tetap.nama,hr_tetap.noFail, yiksys_jantina.jantina_nama FROM hr_tetap, yiksys_jantina WHERE yiksys_jantina.jantina_kod = hr_tetap.jantina_kod order by hr_tetap.nama

HASIL

HASIL SQL adalah= jantina kod telah ditukar dari huruf L kepada LELAKI iaitu field jantina_nama, mengikut penentuan oleh table YIKSYS_JANTINA

Penggunaan Class & Function

1:11 PG 0 Comments A+ a-

File pertama merupakan susulan proses dari form yang menghantar date dalam bentuk DDMMYYYY (mengikut waktu Malaysia). Dan file ini bertindak memanggil file studionixk.php yang terdiri dari function menukar date dari format DDMMYYYY kepada YYYY-MM-DD iaitu format untuk dimasukkan kedalam database MYSQL
 
$TukarTarikhLantik=new FormatTarikh();
$TukarTarikhLantik->SetYYYYMMDD($tarikhLantik);
echo $TukarTarikhLantik->DisplaySetDDMMYYYY();


?>


File 2 iaitu dinamakan studionixk.php adalah penggunaan function SetYYYYMMDD untuk memanggil tarikh pada format DD-MM-YYYY, memecahkan mengikut '-' dan menyusun kembali mengikut format SQL iaitu YYYY-MM-DD. Manakala function DisplaySetDDMMYYYY digunakan untuk display result yang telah diproses didalam function SetYYYYMMDD.
';


tarikhYYYYMMDD= $tarikhDDMMYYYY;
        $PecahkanTigaKapsul=explode('-', $tarikhDDMMYYYY);
        $SusunTigaKapsul=$PecahkanTigaKapsul[2].'-'.$PecahkanTigaKapsul[1].'-'.$PecahkanTigaKapsul[0];
        $this->tarikhYYYYMMDD=$SusunTigaKapsul;
     }

    public function DisplaySetDDMMYYYY()
    
    {
        return $this->tarikhYYYYMMDD;
    }
}
 
 ?>