php数据库连接和mysql语句使用

从简单的登录页开始学习。

前提:已经有一个html+css+js的静态网站

登录:

  php连接数据库,读取数据。

 1 <?php
 2 $username = root;
 3 $userpass = shao;
 4 $dbhost = localhost;
 5 $dbdatabase = mytest;
 6 
 7 //首先生成一个连接
 8 $db_connect = mysql_connect("localhost", "root", "shao") or die("Unable to connect to the MySQL!");
 9 
10 //选择一个操作的数据库
11 mysql_select_db("mytest", $db_connect);
12 
13 //执行增删改查语句
14 mysql_query("select * from user");
15 
16 ?>

 

posted on 2014-11-01 17:04  傅里叶变身  阅读(232)  评论(0编辑  收藏  举报

导航