php新手 幫忙看一下為何while裡面的不執行 謝謝了

來源:互聯網
上載者:User
下面是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 "
".var_dump($row)."
";*/
//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=... 就能看到所有資料庫。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.