Jump to content
php.lv forumi

DB izveide


Zoom

Recommended Posts

Varbut kads man varetu kadu mazu minimalu paraudzinu paradit ka var ar PHP skripta palidzibu izveidot jaunu datu bazi ? Es domaju ieraksta lauka DB nosaukumu un spiez pogu "izveidot".

Edited by Zoom
Link to comment
Share on other sites

Kautka ta ?

<?php
$data = @mysql_connect('localhost', 'einars', '') or die ('sudi nu ir :(');
if(isset($_POST['sutit'])){
$dbname = $_POST['dbname'];
$sql = "create database `{$dbname}`";
}
?>
<form method="post" action="">
<input type="text" name="dbname"><br>
<input type="submit" name="sutit" value="Sutit">
</form>

 

Bet man vins neizveido.. :(

Link to comment
Share on other sites

Nu, raksti:

<?php
$data = @mysql_connect('localhost', 'einars', '') or die ('sudi nu ir :(');
if(isset($_POST['sutit'])){
$dbname = $_POST['dbname'];
$sql = "CREATE DATABASE `".$dbname."`";
}
?>
<form method="post" action="">
<input type="text" name="dbname"><br>
<input type="submit" name="sutit" value="Sutit">
</form>

 

Ja neizveido, pārbaudi vispār, vai tev ir tiesības to izveidot.

Link to comment
Share on other sites

man aizgaja sadi:

<?php
if(isset($_POST['sutit'])){
$dbname = $_POST['dbname'];
$sql = "create database `{$dbname}`";
}
mysql_query($sql) or die(mysql_error());
?>
<form method="post" action="">
<input type="text" name="dbname"><br>
<input type="submit" name="sutit" value="Sutit">
</form>

Link to comment
Share on other sites

tas ir 10 ballu sitema ? :angry: :D

Un vel netaisot jaunu topiku. Kura manueli var atrast (PHP vai MySQL) paraudzinu ka var tabulas ievietot tada pasa veida. Tabulas jau sarakstitas php skripta. Tik skriptam ir jaieliek vinas DB..

Edited by Zoom
Link to comment
Share on other sites

×
×
  • Create New...