PHP креирање на база на податоци
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$conn = new
mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Nema
konekcija: " . $conn->connect_error);
}
$sql =
"CREATE DATABASE mojaDB";
if ($conn->query($sql)
=== TRUE) {
echo
"Bazata e uspesno kreirana
";
} else {
echo
"Greska vo kreiranje na
baza na podatoci : " . $conn->error;
}
$conn->close();
?>
PHP конекција со база на податоци
<?php
$servername =
"localhost";
$username = "username";
$password = "password";
$dbname = "mojaDB";
$conn = new mysqli($servername, $username, $password, $dbname);
$conn->set_charset("utf8");
if ($conn->connect_error) {
die("Nema konekcija : " . $conn->connect_error);
}
else {
echo "ima konekcija";
}
$conn->close();
?>
|