dqj5046 2017-05-25 22:18
浏览 11

错误mysql_num_rows()[重复]

I'm making an user register system with PHP and MySQL. The problem is when I try to verify if the user is already registered I get the following error:

mysql_num_rows() expects parameter 1 to be resource, boolean given

This is my code:

$sql = mysql_query("SELECT identificacion FROM cliente WHERE identificacion='".$usuario_dni."'");
if(mysql_num_rows($sql) > 0) {
                  echo "Esta identificacion ya ha sido utilizada en un registro anteriormente. <a href='javascript:history.back();'>Reintentar</a>";
              }else {
                  //$usuario_clave = md5($usuario_clave); // Encriptamos la contraseña

                  $reg = mysql_query("INSERT INTO cliente VALUES ('".$usuario_nombre."', '".$usuario_apellidos."', '".$usuario_dni."', '".$usuario_fecha."', '"
                    .$usuario_tlfn."', '".$usuario_pais."' ,".$usuario_email."', NOW())");
                  if($reg) {
                      echo "Usuario Registrado con exito.";
                  }else {
                      echo "Ha ocurrido un error y no se ha podido registrar.";
                  }
</div>
  • 写回答

1条回答 默认 最新

  • dongqing4070 2017-05-25 22:22
    关注

    Probably the mysql_query is returning false as boolean value. Make sure you check the value of $sql. Also please notice that mysql_query has been deprecated. Please check following link:

    http://php.net/manual/en/function.mysql-query.php

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大