通过php进行数据库操作的问题

crazypiglrc 2009-11-23 06:37:36
我想进行数据库插入数据操作,但不知道为什么插不进去。并且我确定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();
?>
...全文
85 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
honglei8485 2009-11-23
  • 打赏
  • 举报
回复
写错,是插入语句没 执行
honglei8485 2009-11-23
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xuzuning 的回复:]
mysql_query($requete) or die("impossible d'insérer ".mysql_error());
[/Quote]
查询语句没执行,楼上正解
xuzuning 2009-11-23
  • 打赏
  • 举报
回复
mysql_query($requete) or die("impossible d'insérer ".mysql_error());
yishiwucheng 2009-11-23
  • 打赏
  • 举报
回复
先把SQL语句echo出来看看就知道了,要学习排除法去解决问题
床上等您 2009-11-23
  • 打赏
  • 举报
回复
插入字符中是否含 有非法字符,你可先 echo 出来看看
liuyang1588 2009-11-23
  • 打赏
  • 举报
回复
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");


检查一下 数据库的类型是否和你的sql语句匹配, 文本时间用'' 数字不用

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧