下面是My Code:
$conn=mysql_connect("localhost","root","");
if(!$conn)
die("Could not connect:".mysql_error());
if(!mysql_select_db("user2",$conn))
echo "串連資料庫失敗";
mysql_query("set names utf8",$conn);
mysql_query("create table table1(
id int primary key not null AUTO_INCREMENT,
name varchar(16) not null,
email varchar(16) not null,
age int(16))",$conn);
mysql_query("insert into table1(name,email,age)
values('sun',12345@emial.com,19)",$conn);
echo "hello world!
";
$result=mysql_query("select * from table1",$conn);
while($row=mysql_fetch_row($result))
{
/* echo var_dump($row)."
";
echo "
";*/
//echo "
$row[0]--$row[1]--$row[2]";
foreach($row as $value)
{
echo "--$value";
}
echo "
";
}
echo "hello";
mysql_free_result($result);
mysql_close();
?>
結果:
回複討論(解決方案)
檢查一下table1中是否有資料
上面代碼中不是添加了麼 我通過用戶端查詢不了
我的用戶端查詢的結果只有一個資料庫information_schema 但是data檔案夾下卻有通過php創立的資料庫
命令列下查看一下表是否存在,並且查看錶中是否有資料。
insert into table1(name,email,age)
values('sun', 12345@emial.com,19)
不需要用引號碼?
mysql_query("insert into table1(name,email,age)
values('sun',12345@emial.com,19)",$conn);
這裡沒有插入成功。
mysql_query("insert into table1(name,email,age)
values('sun',12345@emial.com,19)",$conn);
這裡沒有插入成功。
mysql_query("insert into table1(name,email,age)
values('sun',12345@emial.com,19)",$conn) or die(mysql_error());
命令列下查看一下表是否存在,並且查看錶中是否有資料。
這兩個顯示為啥不一樣(也不知道你能不能看到這個回複)
沒建立資料庫一樣,用Navicate Mysql軟體看下。
沒建立資料庫一樣,用Navicate Mysql軟體看下。
那個問題解決了 我想問一下9樓的問題能解決嗎?
你是用什麼使用者登入的?
你是用什麼使用者登入的?
這個麼 沒有登陸啊 就是在mysql中bin檔案夾下面有個mysql.exe 然後show databases 出來的
你是以當前windows使用者登入mysql的,所以只能看到你能看到的資料庫。
運行:mysql.exe with --user=root --password=... 就能看到所有資料庫。
太謝謝你了!
你是以當前windows使用者登入mysql的,所以只能看到你能看到的資料庫。
運行:mysql.exe with --user=root --password=... 就能看到所有資料庫。