1. 建立数据库连接
<?php
$mysqli = new mysqli("localhost","root","","mydb");
?>
建立一个数据库连接需要四个参数,分别为数据库地址、数据库访问用户名、数据库访问密码、数据库名称。除了使用上面的mysqli对象的构造方法建立数据库连接外,还可以调用其connect方法建立数据库的连接。
<?php
$mysqli = new mysqli();
$mysqli->connect("localhost","root","","mydb");
?>
还可以通过mysqli对象的构造方法建立数据连接,通过select_db方法指定要访问的数据库。
<?php
$mysqli = new mysqli("localhost","root","");
$mysqli->select_db("mydb");
?>
通过mysqli对象的errno属性获取当前连接的错误号,如果当前连接没有任何错误,错误号返回为0。
<?php
$mysqli = new mysqli("localhost","root","");
$mysqli->select_db("mydb");
if($mysqli->errno == 0) //判断当前连接是否成功
{
}
else
{
echo "The Connection is Error!";
exit();
}
?>
当然可以通过mysqli对象的error属性获取当前连接的错误信息,如果没有错误,返回“”。
<?php
$mysqli = new mysqli("localhost","rootsss","");
$mysqli->select_db("mydb");
if($mysqli->errno == 0) //判断当前连接是否成功
{
}
else
{
echo $mysqli->error; //输出当前错误信息
exit();
}
?>
波比源码 » PHP5操作MySQL数据库
levaquin 500mg cost order levaquin generic
buy generic isotretinoin 20mg amoxicillin 1000mg drug where to buy ivermectin pills
cialis overnight shipping usa Cialis overnight sildenafil price
buy sporanox 100 mg generic order prometrium 100mg without prescription buy tindamax 300mg online
tadalafil 20mg uk sildenafil 50mg drug sildenafil for men
sildenafil next day delivery usa lamotrigine online buy lamictal generic
buy sildenafil 100mg pills viagra pharmacy tadalafil cheap
ocean casino online buy generic tadalafil 5mg tadalafil 10mg without prescription
prednisone 40mg without prescription cost prazosin 2mg buy mebendazole 100mg pills
singulair over the counter viagra 100mg brand us viagra
buy actos for sale buy pioglitazone online sildenafil 100mg tablets
tadalafil 5mg oral Cialis woman casino money
stromectol 2mg online buy stromectol 12mg generic brand dapsone 100mg
generic adalat order adalat 30mg pill buy allegra pills
casino games free vegas casino online free online blackjack
real casinos online no deposit burton brunette buying essay
doxycycline 100mg for sale brand cleocin 150mg cleocin 150mg ca
buying a research paper letter editing order azulfidine 500mg for sale
benicar online order buy benicar 20mg online buy generic divalproex 250mg
diamox 250 mg pill oral azathioprine 25mg order azathioprine 25mg online cheap
order amoxil generic buy stromectol 3mg sale ivermectin price uk
order indocin pill cenforce tablet order generic cenforce 50mg
tadacip uk order tadacip 20mg generic buy trimox 500mg generic
Thank you for great content. Hello Administ. Onwin , Onwin Giriş , Onwin Güncel Giriş , Onwin Yeni Adres , onwin
order cialis 40mg pill Low price cialis viagra cheap
buy minocycline 50mg without prescription neurontin tablets buy hytrin 1mg pill
order generic glycomet buy tamoxifen 10mg pills tamoxifen 10mg us
buy modafinil 200mg without prescription buy stromectol 3mg online purchase promethazine generic
purchase clomid without prescription lipitor canada prednisolone usa
isotretinoin 40mg uk buy deltasone 5mg online cheap ampicillin 250mg oral
buy ondansetron 4mg generic ondansetron brand purchase bactrim pill
ivermectin pills canada order deltasone 40mg online buy deltasone 10mg sale
buy albuterol purchase augmentin without prescription buy augmentin 625mg generic
order isotretinoin brand amoxicillin 250mg buy azithromycin 500mg pill
dutasteride over the counter dutasteride us order orlistat 60mg pill
monodox price buy doxycycline pills purchase zovirax pills
oxybutynin 5mg sale prograf 5mg for sale order oxcarbazepine 300mg
buy alfuzosin 10 mg sale diltiazem 180mg tablet buy diltiazem 180mg without prescription
ezetimibe 10mg usa order methotrexate 2.5mg online cost methotrexate 2.5mg
purchase coumadin without prescription warfarin 5mg us allopurinol 100mg usa