Home > Article > Backend Development > Two ways to connect to MYSQL through PHP 2_PHP tutorial
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",