好了,我有這樣的代碼:數據庫創建使用PHP和MySQL
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpwd = 'ALLO';
$dbname = 'test';
$conn = mysqli_connect($dbhost, $dbuser, $dbpwd, $dbname);
if(! $conn)
{
die("\nconn: $conn \nCould not connect: " . mysqli_error($conn));
}
echo "\n";
$createtab="CREATE TABLE People(FirstName CHAR(30),LastName CHAR(30),Age INT)";
// Execute query
if (mysqli_query($conn,$createtab))
{
echo "Table created successfully";
}
else
{
echo "Error creating table: " . mysqli_error($conn);
}
echo "\n";
mysqli_query($conn,"INSERT INTO People (FirstName, LastName, Age)
VALUES ('Peter', 'Griffin',35)");
mysqli_query($conn,"INSERT INTO People (FirstName, LastName, Age)
VALUES ('Glenn', 'Quagmire',33)");
mysqli_close($conn)
?>
當我運行PHP腳本,它運行良好。
但是,我無法在mysql工作臺中找到表。
我刷新了很多次。
http://i.stack.imgur.com/uX1sQ.png http://i.stack.imgur.com/iEXqT.png
phpmyadmin它說什麼? – Mihai
我使用'HeidiSQL'運行查詢,表格和行顯示在我的... –
哦,它可能是mysql工作臺沒有選擇默認的db.Insert在你的代碼CREATE DATABASE等等; USE等等;在創建表之前.OR只是使用現有的數據庫。 – Mihai