?php$server = "localhost";
弓長嶺ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
$username = "root";
$password = "";
$database = "myabc";
$ranks = array(
1="newbie",
2="new member",
3="member",
4="high member",
5="very high member",
6="supreme member",
7="ultra member",
8="godlike member",
9="god member",
10="low god",
11="medium god",
12="high god",
13="very high god",
14="supreme god",
15="ultra god",
16="perfect");$couldNotOpenDatabase = "Could not open databaseBR\n please check your settings in config.php";
$couldNotConnectMysql="Could not connect Mysql!";
$conn=mysql_connect($server,$username,$password) or die ($couldNotConnectMysql);
if (mysql_select_db($database,$conn))
{//數(shù)據(jù)庫存在,做相應(yīng)操作}else{//數(shù)據(jù)庫不存在,創(chuàng)建一個(gè),并做相應(yīng)操作
創(chuàng)建數(shù)據(jù)庫:create database 數(shù)據(jù)庫名
創(chuàng)建數(shù)據(jù)表:
CREATE TABLE `users` (
`id` tinyint(10) auto_increment primary key NOT NULL,
`username` varchar(30) NOT NULL,
`age` int(10) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
執(zhí)行這兩個(gè)sql語句就行
關(guān)于phpmyadmin創(chuàng)建表代碼怎么寫方法如下
php這門語言在現(xiàn)今極為流行,甚至在有的學(xué)習(xí)網(wǎng)站上把php語言放到了Java語言之前,可見這門語言的廣泛接受度。我們學(xué)習(xí)php的軟件有很多,不在敘述,而服務(wù)器我們一般會(huì)統(tǒng)一采用wampserver軟件,wampserver是php的集成開發(fā)環(huán)境,里面也包含了phpmyadmin,現(xiàn)在我們來看看怎么用phpmyadmin創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表。
01
登陸phpmyadmin主頁的方法(1)方法一:雙擊桌面上的wampserver軟件圖標(biāo),然后等圖標(biāo)由紅色變成綠色之后,右擊,選擇【phpmyadmin】,即可登陸進(jìn)來。這個(gè)方法是比較常用的而且是最為簡單的方法。
02
登陸phpmyadmin主頁的方法(2)方法二:在瀏覽器地址欄中輸入,其中8085是wampserver的端口號(hào),wampserver的默認(rèn)端口號(hào)是8080,但是會(huì)跟tomcat等沖突導(dǎo)致軟件不能使用,因此一般將其端口號(hào)設(shè)置成8085等。輸入正確地址之后,按鍵盤上的回車鍵即可登陸到phpmyadmin主頁中來。
首先你把這個(gè)sql語句賦給一個(gè)字符串變量:
$sql="CREATE TABLE IF NOT EXISTS `{$installer-getTable('catalog_category_description')}` (
`category_id` mediumint(8) unsigned NOT NULL,
`language_id` smallint(5) unsigned NOT NULL,
`name` varchar(128) NOT NULL,
`description` text NOT NULL,
`meta_title` varchar(128) NOT NULL,
`meta_description` text NOT NULL,
`meta_keyword` varchar(255) NOT NULL,
PRIMARY KEY (`category_id`,`language_id`),
KEY `i_language_id` (`language_id`),
CONSTRAINT `fk_category_id` FOREIGN KEY (`category_id`) REFERENCES `{$installer-getTable('catalog_category')}` (`id`) ON DELETE CASCADE,
CONSTRAINT `fk_language_id` FOREIGN KEY (`language_id`) REFERENCES `{$installer-getTable('locale_language')}` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC";
然后連接mysql數(shù)據(jù)庫,執(zhí)行這個(gè)語句:
mysql_connect("localhost","root","");
mysql_select_db("dbname");
mysql_query($sql);
就可以了。
注意連接數(shù)據(jù)庫帳號(hào)的權(quán)限要有創(chuàng)建表的權(quán)限,否則創(chuàng)建就不會(huì)成功!