Home  >  Article  >  Backend Development  >  Two ways to connect to MYSQL through PHP 2_PHP tutorial

Two ways to connect to MYSQL through PHP 2_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:27:19833browse

Two methods of connecting to MYSQL through PHP
Copyright: bluemy/php Chinese users
Please contact the author for reprinting
Examples can be found in my article in the "Programs and Codes" of this website and the following routines :
Front Desk HTML
You can take some time to fill in the form below, or you can contact us via
email, likai333@21cn.com.
Your name:
Your email:
Website address you want to advertise on:
Website name you want to advertise on:
Your company name:
You Contact number:

Backend 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 "An error occurred, please notify me";
echo "$err";
}
else
{ echo "Successful storage"; }
? >
Table structure:
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",
);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531888.htmlTechArticleTwo methods of connecting to MYSQL through PHP Copyright: bluemy/php Chinese users please contact the author for reprinting. For examples, see me The articles and the following routines in the "Programs and Codes" of this website: Front Desk...
Statement:
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