检查用户是否已拥有PHP& ORACLE

时间:2014-06-05 11:53:49

标签: php oracle

我试图在注册表单上应用最后润色。我想根据用户的电子邮件地址检查用户是否已经拥有帐户。然而,PHP不会帮助我。这是我的代码的主要部分。

$s = oci_parse($conn, "SELECT * FROM users WHERE mail='&mail'");
    oci_execute($s);
    $rows = 0;
    while (oci_fetch($s))
    {
        $rows ++ ;
    }
    echo $rows;  -> this echos all the time 0 even if I have 10+ registered users with same email
    if($rows > 0)
    {
       //has account
    }
    else{

       doesn't have account, inserting into DB
    }

似乎$ rows的值总是0,无论我做什么。我也试过

SELECT COUNT(*) FROM users WHERE mail='$mail'

但我无法将正确的值传递给$ rows变量。

其他一切在我的PHP代码中运行正常。 提前致谢

1 个答案:

答案 0 :(得分:0)

错误来自您编写的sql语句和$ mail邮件。 顺便计算你的行你可以使用函数oci_num_rows($s)使用这个函数你不必使用while循环