简体   繁体   English

检查用户是否已经拥有PHP和ORACLE帐户

[英]Checking if user already has account with PHP & ORACLE

I'm trying to apply the finishing touches on a register form. 我正在尝试在注册表上应用画龙点睛的功能。 I want to check if the user already has an account, based on his e-mail address. 我想根据用户的电子邮件地址检查该用户是否已经拥有一个帐户。 However, the PHP won't help me out. 但是,PHP不会帮助我。 Here is the main part of my code. 这是我的代码的主要部分。

$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
    }

It seems like the value of $rows is always 0, no matter what I Do. 无论我做什么,似乎$ rows的值始终为0。 I also tried with 我也尝试过

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

But i was unable to pass the correct value to the $rows variable. 但是我无法将正确的值传递给$ rows变量。

Everything else works fine in my php code. 其他一切都可以在我的php代码中正常工作。 Thanks in advance 提前致谢

The error comes from the sql statement you have written &mail insted of $mail. 该错误来自您在$ mail中写入&mail插入的sql语句。 And by the way to count your rows you can use the function oci_num_rows($s) with this function you dont have to use the while loop 顺便说一句,您可以使用oci_num_rows($s)函数来计算行数,而不必使用while循环

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM