Created
January 30, 2018 01:51
-
-
Save malikkurosaki/232ffc0493558ec008e4f530c78519fe to your computer and use it in GitHub Desktop.
php oo to insert data to database mysqli simple
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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