色www,五月婷婷深爱五月,午夜国产一级片,色噜噜综合,国产大胸无码视频,清纯美女被操黄网站在线观看,波多野结衣av高清一区二区三区

PHP如何創(chuàng)建數(shù)據(jù)庫

時間:2025-12-20 13:06:09 php語言 我要投稿

PHP如何創(chuàng)建數(shù)據(jù)庫

  MySQL是最流行的開源數(shù)據(jù)庫服務(wù)器,那我要使用PHP在MySQL的數(shù)據(jù)庫創(chuàng)建一張表,實現(xiàn)通過PHP操作數(shù)據(jù),那我們先要獲取連接,拿到MySQL數(shù)據(jù)庫的賬號密碼。下面就跟隨小編一起來看看吧!

  PHP創(chuàng)建數(shù)據(jù)庫

  $con = mysql_connect('localhost', 'root', 'root');

  /************************在數(shù)據(jù)庫中創(chuàng)建表*************************/

  if (!$con) {

  die ('連接數(shù)據(jù)庫出錯: ' . mysql_error());

  }

  $database="my_db_name";

  $sqlDatabase = 'create database '.$database;

  if(mysql_query($sqlDatabase, $con))

  {

  echo "恭喜你,數(shù)據(jù)庫".$database."創(chuàng)建成功了!";

  }

  else

  {

  echo "創(chuàng)建數(shù)據(jù)庫出錯,錯誤號:".mysql_errno()." 錯誤原因:".mysql_error();

  }

  /******************************end***************************************/

  /************************在數(shù)據(jù)庫中創(chuàng)建表*************************/

  mysql_select_db("my_db_name",$con);

  $sqlTable="create table my_table_name (

  id int unsigned not null auto_increment primary key,

  a var20),

  b var2),

  c var1))";

  if(mysql_query($sqlTable))

  {

  echo "恭喜你,數(shù)據(jù)表創(chuàng)建成功了!";

  }

  else

  {

  echo "創(chuàng)建數(shù)據(jù)表出錯,錯誤號:".mysql_errno()." 錯誤原因:".mysql_error();

  }

  /******************************end***************************************/

  /*************************在表中寫入數(shù)據(jù)*********************************/

  /pic/p>

  /pic/pic/p>

  /pic/pic/p>

  $sql = " into my_table_name(a,b) values ('123','45')"; /pic/p>

  if(mysql_query($sql))/pic/p>

  {

  echo "恭喜你,表中寫入數(shù)據(jù)成功了!";

  }

  /******************************end***************************************/

  mysql_close();

  ?>

【PHP如何創(chuàng)建數(shù)據(jù)庫】相關(guān)文章:

PHP如何插入數(shù)據(jù)庫03-09

php如何連接數(shù)據(jù)庫05-19

如何在PHP中連接MySQL數(shù)據(jù)庫04-13

php網(wǎng)站如何連接到遠程mysql數(shù)據(jù)庫04-11

PHP訪問數(shù)據(jù)庫04-27

php數(shù)據(jù)庫備份腳本04-07

PHP插入數(shù)據(jù)庫的方法03-12

PHP怎么插入數(shù)據(jù)庫02-07

PHP數(shù)據(jù)庫連接的方法05-23

  • 相關(guān)推薦