Skip to content

Instantly share code, notes, and snippets.

@malikkurosaki
Created January 30, 2018 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malikkurosaki/232ffc0493558ec008e4f530c78519fe to your computer and use it in GitHub Desktop.
Save malikkurosaki/232ffc0493558ec008e4f530c78519fe to your computer and use it in GitHub Desktop.
php oo to insert data to database mysqli simple
<?php
$host = "127.0.0.1:3306";
$user = "root";
$pass = "";
$db = "malikdata";
$line = new mysqli($host,$user,$pass,$db);
if($line->connect_error){
echo "<br>connection error".$line->connect_error;
}else{
echo "connection succsesfuly<br>";
}
$sql = "INSERT INTO halaman(judul,content)VALUES('halaman satu','kontent satu')";
if($line->query($sql) === TRUE){
echo "berhasil memasukkan data<br>";
}else{
echo "error".$sql."koneksi".$line->error;
}
$line->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment