Home > php教程 > php手册 > 通过PHP连接MYSQL的两种方法(2)

通过PHP连接MYSQL的两种方法(2)

WBOY
Release: 2016-06-21 09:15:04
Original
1120 people have browsed it

mysql

例子可见我在本网站的"程序与代码"里的文章和下面的例程:

前台HTML



您 可 以 花 些 时 间 填 写 下 表 , 也 可 以 用 电
子 邮 件 联 系 ,likai333@21cn.com。


您的姓名:



您的电子邮件:



您欲做广告的网站地址:



您欲做广告的网站站名:



您的公司名称:



您的联系电话:



后台PHP

$dbh = mysql_connect('localhost:3306','root','');
mysql_select_db('HBWEB');
$query ="insert into usemsg ( name,usermail,userurl,sitename, company,phone) values ('$name','$usermail','$userurl', '$sitename', '$company','$phone','$C1','$C2','$C3','$C4','$C5')";
$res = mysql_query($query, $dbh);
$err = mysql_error();
if($err){
echo "发生错误,请通知我";
echo "$err";
}
else
{ echo "成功入库"; }

? >

表结构:

CREATE TABLE usemsg (
name varchar(255) not null default "notname",
usermail varchar(255) not null default "notusermail",
userurl varchar(255) not null default "notuserurl",
sitename varchar(255) not null default "notsitename",
company varchar(255) not null default "notcompany",
phone varchar(255) not null default "notphone",
);



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template