Php 我的语法有什么错误?

Php 我的语法有什么错误?,php,oracle,Php,Oracle,我有一个简单的do_signup.php部分代码: <?php $conn=oci_connect('system', 'user'); if(!$conn){ echo 'Can not connect'; } $uname=$_POST['username']; $pass=$_POST['password']; $pstmt1="select * from admin where username='$uname'"; $stdi1=oci_parse($conn, $pstmt1

我有一个简单的do_signup.php部分代码:

<?php
$conn=oci_connect('system', 'user');
if(!$conn){
echo 'Can not connect';
}

$uname=$_POST['username'];
$pass=$_POST['password'];
$pstmt1="select * from admin where username='$uname'";
$stdi1=oci_parse($conn, $pstmt1);
oci_execute($stdi1);
oci_fetch($stdi1);
$numrow=oci_num_rows($stdi1);

if($numrow==0){
    $pstmt2="insert into admin(username,password) values('$uname', '$pass')";
    $stdi2=oci_parse($conn, $pstmt2);
    oci_execute($stdi2);

    oci_close($conn);
    header('Location: signup_success.php');
}else{
    oci_close($conn);
    header('Location: signup_fail.php');
}

?>

变量名为:$stdi1

然后执行:$stdi

oci\u execute($stdi)中的
$stdi
替换为
$stdi1

编辑: 请看php手册:

您必须获取结果,才能使用
oci\u num\u rows
函数返回获取的行(select),而不是像DML查询那样返回受影响的行

比如:

变量名为:$stdi1

然后执行:$stdi

oci\u execute($stdi)中的
$stdi
替换为
$stdi1

编辑: 请看php手册:

您必须获取结果,才能使用
oci\u num\u rows
函数返回获取的行(select),而不是像DML查询那样返回受影响的行

比如:

第一个错误:

$pstmt1="select * from admin where username='$uname'";//remove extra semicolon
第二个错误:

$pstmt2=“插入管理员(用户名、密码)值(“$uname”、“$pass”)”//删除额外的分号并以正确的方式编写插入语法

首先错误:

$pstmt1="select * from admin where username='$uname'";//remove extra semicolon
第二个错误:


$pstmt2=“插入管理员(用户名、密码)值(“$uname”、“$pass”)”//删除多余的分号并以正确的方式编写插入语法

您可以尝试以下操作

oci_define_by_name($stmt, 'NUMBER_OF_ROWS', $number_of_rows);
oci_execute($stmt);
oci_fetch($stmt);
echo $number_of_rows;

你可以试试下面的方法

oci_define_by_name($stmt, 'NUMBER_OF_ROWS', $number_of_rows);
oci_execute($stmt);
oci_fetch($stmt);
echo $number_of_rows;

分号和插入语法已编辑,但仍有问题。输入现有值仍将重定向到signup_success。phpsemicolon和插入语法已编辑,但仍有问题。输入现有值仍将重定向到signup_success。php出现其他问题。早些时候,当我输入相同的值时,我总是被重定向到signup_success.php。现在,当我的表为空时,我总是被重定向到signup_fail.php。将测试更改为如果(!$numrow>0)您的条件与我的条件相同。函数是否有可能返回-1或null?我的管理表为空,它必须返回null或0并接受新值,但我总是被重定向到注册失败。出现了其他问题。早些时候,当我输入相同的值时,我总是被重定向到signup_success.php。现在,当我的表为空时,我总是被重定向到signup_fail.php。将测试更改为如果(!$numrow>0)您的条件与我的条件相同。函数是否有可能返回-1或null?我的管理表为空,它必须返回null或0并接受新值,但是我总是被重定向到注册失败。phpSo他必须改变
SELECT*FROM…
SELECT count(1)NUMBER\u FROM…
。所以他必须改变
SELECT*FROM…
SELECT count(1)NUMBER\u FROM…