PHP连接MYSQL数据库
<p>04级新生名单</p>
<table border="1" width="80%" cellpadding="0">
<tr>
<td width="10%" align="center">Id</td>
<td width="20%" align="center">Name</td>
<td width="10%" align="center">Age</td>
<td width="10%" align="center">Sex</td>
<td width="30%" align="center">Address</td>
<td width="20%" align="center">DoWith</td>
</tr>
<?php
//连接数据库
//打开一个连接,连接到本地mysql数据库
$conn=mysql_connect("localhost","root","dalyluo");//ip,user,pwd
//选择操作的资料库
mysql_select_db("test",$conn);// 资料库名称,连接
$sql="select * from student";
//用mysql_query函数从资料库中查询
mysql_query("set names gbk");//处理中文乱码问题,gbk可以是其它值
$result=mysql_query($sql,$conn);// search sql, connection
//循环读取记录
while($row=mysql_fetch_array($result)){
?>
<tr>
<td width="10%" align="center"><?php echo $row["stuid"] ?></td>
<td width="20%" align="center"><?php echo $row["stuname"] ?></td>
<td width="10%" align="center"><?php echo $row["stuage"] ?></td>
<td width="10%" align="center"><?=$row["stusex"]?></td>
<td width="30%" align="center"><?=$row["stuaddress"]?></td>
<td width="20%" align="center"><a href="#" mce_href="#" onClick="<?php doDel($row["stuid"]) ?>">删除</a></td>
</tr>
<?php
}
//关闭连接
mysql_close($conn);
function doDel($sid){
global $conn;
mysql_select_db("test",$conn);
$del_sql="delect from student where stuid="+$sid;
mysql_query($del_sql,$conn);
}
?>
</table>
相关文档:
搞了很久。。终于发现原来是权限问题。。
2行命令搞定
grant all privileges on rogue.* to admin@localhost identified by 'admin' with grant option
grant all privileges on rogue.* to admin@'%' identified by 'admin' with grant option
经典了。。。
魔力私服网页端搞定咯~~ ......
<?php
* xCopy("feiy","feiy2",1):拷贝feiy下的文件到 feiy2,推销员的一天,包括子目录
*参数说明:
* $destination:目的目录名
......
PHP环境配置心得
Apache的配置
首先我在http://httpd.apache.org/download.cgi下的是“Win32 Binary without crypto (no mod_ssl) (MSI Installer): httpd-2.2.15-win32-x86-no_ssl.msi”。安装那是小儿科啦,下一步下一步。我就不说了。
安装完后就要开始配置了, ......
我们知道用powerdesigner导出的sql文件后缀为'.sql';用phpmyadmin很容易导入MysQL数据库,但是用PHP怎么导入数据库呢?
我用powerdesigner设计一个数据库后导出sql文件(一个投票系统)为'vote.sql';
文件内容为(一些sql语句和注释):
/*======================= ......
PHP中文乱码是PHP开发中的常见问题之一。PHP中文乱码有时发生在网页本身,有些产生在于MySQL交互的过程中,有时与操作系统有关。下
面进行一番总结。
一.首先是PHP网页的编码
1. php文件本身的编码与网页的编码应匹配
a. 如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; ......