《PHP mysql資料連線簡單示例》

2021-06-10 05:02:07 字數 1131 閱讀 2734

<?php 

/*create table user1(

id int primary key auto_increment,

name varchar(32) not null,

password varchar(64) not null,

email varchar(32) not null,

age tinyint unsigned not null

);insert into user1(name,password,email,age)values('wxf',md5('123'),'[email protected]',30);

insert into user1(name,password,email,age)values('zhangsan',md5('456'),'[email protected]',30);

insert into user1(name,password,email,age)values('lisi',md5('789'),'[email protected]',30);

*/ //1.獲取連線

$conn = mysql_connect("localhost","root","123");

if (!$conn)else

//2.選擇資料庫

mysql_select_db("test");

//設定編碼

mysql_query("set names utf-8");

$res = mysql_query($sql, $conn);

$sql = "select * from user1";

//3.接受資源

$res = mysql_query($sql, $conn);

while ($row = mysql_fetch_row($res))

echo "

"; }

//4.釋放資源必須有

mysql_free_result($res);

//關閉mysql連線,寫與不寫效果不大

php mysql 鍊錶 PHP鍊錶操作簡單示例

在php中執行資料結構,基本都是用陣列模擬的,只是用一直思想而已。今天遇到的這個問題是,兩個鍊錶進行合併。鍊錶合併效果圖 問題描述 a鍊錶是模版鍊錶,b鍊錶的長度不確定,a,b二個鍊錶結合後形成c鍊錶。說一下程式設計思想 a鍊錶是模版鍊錶所以在運算完成了,長度了唯一不變的。而b鍊錶的長度是不確定的。...

PHP Mysql資料庫連線

1,date default timezone set prc 獲取北京時區 header content type text html charset utf 8 編碼 define db host localhost 資料庫位址,一般為localhost define db user root ...

PHP MySQL 連線資料庫

免費的 mysql 資料庫通常是通過 php 來使用的。在您能夠訪問並處理資料庫中的資料之前,您必須建立到達資料庫的連線。在 php 中,這個任務通過 mysql connect 函式完成。mysql connect servername,username,password 引數 描述servern...