php怎么获得数据库 php怎么获得数据库信息

php如何获取用的什么数据库

进入php源程序目录中的ext目录中,这里存放着各个扩展模块的源代码,选择你需要的模块,比如curl模块:cd curl

10年积累的做网站、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有海港免费网站建设让你可以放心的选择与我们合作。

执行phpize生成编译文件,phpize在PHP安装目录的bin目录下

/usr/local/php5/bin/phpize

运行时,可能会报错:Cannot find autoconf. Please check your autoconf installation and

the $PHP_AUTOCONF

environment variable is set correctly and then rerun this

script.,需要安装autoconf:

yum install autoconf(RedHat或者CentOS)、apt-get install

autoconf(Ubuntu Linux)

/usr/local/php5/bin/php -v

执行这个命令时,php会去检查配置文件是否正确,如果有配置错误,

这里会报错,可以根据错误信息去排查!

如何用php获取数据库信息并显示

获取ppq数据库的所有表名的代码:

?php

$server='localhost';

$user='root';

$pass='12345';

$dbname='ppq';

$conn=mysql_connect($server,$user,$pass);

if(!$conn)

die("数据库系统连接失败!");

$result=mysql_list_tables($dbname);

if(!$result)

die("数据库连接失败!");

while($row=mysql_fetch_row($result))

{

echo

$row[0]."

";

}

mysql_free_result($result);

?

mysql_list_tables

(PHP

3,

PHP

4

,

PHP

5)

mysql_list_tables

--

列出

MySQL

数据库中的表

说明

resource

mysql_list_tables

(

string

database

[,

resource

link_identifier])

mysql_list_tables()

接受一个数据库名并返回和

mysql_query()

函数很相似的一个结果指针。用

mysql_fetch_array()或者用mysql_fetch_row()来获得一个数组,数组的第0列就是数组名,当获取不到时

mysql_fetch_array()或者用mysql_fetch_row()返回

FALSE。

php如何获取数据库信息

代码如下:?View

Code

PHP

include("conn.php");//调用数据库连接文件

echo

"table

width=572

height=56

border=0

cellspacing=1

";

//创建html表格

echo

"tr

bgcolor=#9999FF";

echo

"th

width=33

scope=colid/th";

echo

"th

width=100

scope=coluser_name/th

";

echo

"th

width=100

scope=coluser_pass/th

";

echo

"th

width=100

scope=colstaus/th";

echo

"th

width=100

scope=colinsert_time/th";

echo

"/tr";

$SQL

=

"select

*

from

user_info";

$query

=

mysql_query($SQL);

//SQL查询语句

while

($row

=

mysql_fetch_array($query)){

//使用while循环mysql_fetch_array()并将数据返回数组

echo

"tr

onmouseout=this.style.backgroundColor=''

onMouseOver=this.style.backgroundColor='#99CC33'

bgcolor=#CCCCCC";

echo

"td$row[0]/td";

//输出数组中数据

echo

"td$row[1]/td";

echo

"td$row[2]/td";

echo

"td$row[3]/td";

echo

"td$row[4]/td";

echo

"/tr";

}

echo

"/table";输出记录截图

php如何通过读取数据库?

我建议一下吧,文本数据库的例子本来太多,但是为了逻辑简化,最好通过专门接口实现文件与数据的转换,可以采用我下面的模板编写:

?php

//文件最前面定义两个全局变量,数据库文件名和用户数组

$pwd_db_file='db.txt';

$UserPassword=array();

//下面的pwd_db_read函数,把文件内容读入到全局数组中

function pwd_db_read(){

global $pwd_db_file, $UserPassword;

$fp=fopen($pwd_db_file,'r');

while ($s=fgets($fp)){

list($usr,$pwd)=explode('|', $s);

$UserPassword[$usr]=$pwd;

}

fclose($fp);

}

//下面的pwd_db_write函数保存数组内容到文件中

function pwd_db_write(){

global $pwd_db_file, $UserPassword;

fp=fopen($pwd_db_file, 'w');

foreach ($UserPassword as $usr=$pwd)

fputs($fp,"$usr|$pwd\n");

fclose($fp);

}

//有了上面的全局变量和函数,要写什么功能都简单

//下面假释本脚本调用的时候通过reg.php?job=adduser=...pass=...

//的格式进行调用,job为add表示添加用户,del表示删除,modi表示修改

//另外的user和pass表示用户名或者密码,job不是以上内容表示登录

//主程序一开始就打开数据库

pwd_db_read();

//下面判断功能

if ($jon=='add'){

if (array_key_exists($user,$UserPassword)) echo "用户 $user 已经存在!"

else $UserPassword[$user]=$pass;//就一句话,简单吧

}elseif (job=='del'){

unset($UserPassword[$user]);//你自己考虑编写是否确认删除的内容

}elseif ($job=='modi'){

if (array_key_exists($user,$UserPassword)) $UserPassword[$user]=$pass;//和添加是不是有点类似

else echo "用户 $user 不存在!"

}else{

if ($UserPassword[$user]==$pass){

echo '密码正确。';

//接下来可能要做许多事情

}else echo '密码错误!';

}

//程序最后保存数据库修改

pwd_db_write();

?

看得懂吗,没有上机调试,语法问题可能难免,如果发现不明白的问题请补充。

文章题目:php怎么获得数据库 php怎么获得数据库信息
文章分享:https://www.cdcxhl.com/article8/ddgcsop.html

成都网站建设公司_创新互联,为您提供企业网站制作品牌网站制作微信小程序电子商务虚拟主机自适应网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都seo排名网站优化