Crearea unei baze de date

postat acum 4 ani de Stefanescu Mihai in categorie PHP

Pentru a crea sau sterge o baza de date trebuie sa aveti privilegii de administrator. Este usor sa creezi o noua baza de date MySQL. Puteti folosi functia query().

Sintaxa:

$mysqli->query( query-ul );

Exemplu:

<?php
$host = 'localhost';
$user = 'user';
$pass = 'parola';
$conn = new mysqli($host, $user, $pass);
if ($conn->connect_errno) {
    echo "Nu ma pot conecta: (" . $conn->connect_errno . ") " . $conn->connect_error;
}

echo 'M-am Conectat';
$sql = 'CREATE Database test_mike';

$retval = $conn->query($sql);

if( !$retval ){
  die('N-am putut crea baza de date: ');
}

echo "Baza de date test_mike a fost creata\n";

$conn->select_db('test_mike');

$conn->close();
?>

Explicatii:

In primul rand am m-am conectat la baza de date folosind new mysqli(‘host’, ‘user’, ‘parola’), iar apoi am creat o noua baza de date folosind un query SQL (Vezi lectii SQL). Dupa ce am creat baza de date am selectat-o folosind functia select_db( ‘baza de date’ );

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group
Acest articol a fost mutat de pe vechea platforma.
Pentru orice eroare aparuta la mutare va rog sa ma contactati!

Comentariu postate de download minecraft free la data de 14.05.2019
Yesterday, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is entirely off topic but I had to share it with someone!
Comentariu postate de mlb jerseys la data de 16.05.2019
I actually wanted to compose a brief comment in order to say thanks to you for these awesome ideas you are giving out here. My particularly long internet search has now been recognized with reliable strategies to talk about with my family members. I would assume that we visitors are unequivocally fortunate to live in a fine site with very many awesome people with helpful tricks. I feel somewhat happy to have encountered the webpage and look forward to many more excellent minutes reading here. Thanks a lot once again for everything.
Comentariu postate de minecraft download for free la data de 17.05.2019
I visited several blogs except the audio quality for audio songs present at this web site is truly excellent.