通过php进行数据库操作的问题
我想进行数据库插入数据操作,但不知道为什么插不进去。并且我确定table名和column名都没错,连接也没有问题,页面执行也没有出错,但就是数据库中无数据。红线部分为插入的语句。很急,谢谢了
我的程序如下
<?php
$host="localhost";
$user="root1";
$bdd="site immo";
$passwd="";
$mabase=mysql_connect($host, $user, $passwd) or die("erreur de connexion au serveur");
mysql_select_db($bdd) or die("erreur de connexion a la base de donnees");
$requete="select * from adherent";
$result=mysql_query($requete);
$row=mysql_fetch_array($result);
echo $row["NomAdherent"];
if ((!empty($_POST['nom'])) and (!empty($_POST['prenom'])) and (!empty($_POST['login'])) and (!empty($_POST['mdp1'])) and (!empty($_POST['mdp2'])) and (!empty($_POST['tel'])) and (!empty($_POST['email']))) {
$requete='select login from site immo.adherent';
$result=mysql_query($requete,$mabase);
$i=0;
if ($result!=NULL){
while ($i<mysql_num_fields($result)){
$meta=mysql_fetch_field($result,$i);
if ($meta==$_POST['login']) continue;
$i++;
}
$numadherent=mysql_num_fields($result)+1;
}
else $numadherent=1;
if ($result==NULL or $meta!=$_POST['login']) {
if ($_POST['mdp1']==$_POST['mdp2']){
$mdp=$_POST['mdp1'];
$nom=$_POST['nom'];
$login=$_POST['login'];
$prenom=$_POST['prenom'];
$tel=$_POST['tel'];
$email=$_POST['email'];
echo $login.$mdp.$nom.$prenom.$tel.$email;
$requete="INSERT INTO adherent (NumAdherent,LoginAdherent,MdpAdherent,NomAdherent,PrenomAdherent,TelAdherent,EmailAdherent) VALUES ('$numadherent','$login','$mdp','$nom','$prenom','$tel','$email')";
mysql_query($requete) or die("impossible d'insérer");
}
else{
Header("Location: inscrit.html");
}
}
else{
Header("Location: inscrit.html");
}
}else{
Header("Location: inscrit.html");
}
mysql_close();
?>