我在做一些可笑的愚蠢的事情吗?一切正常,直到你好(2)
而 (mysqli_stmt_fetch($selectCust)) 不会执行。我一步一步地经历了一切,条目出现在数据库中。如果条目是原始的,则 if 语句将正确执行。
我最初在 mysql 中完成了整个表单,并且效果很好。我只是无法让 fetch 与准备好的语句一起工作,所以我确定这不是逻辑错误。
Creating prepared statements and binding params
$insertCust = mysqli_prepare($mysqli,
"INSERT INTO `mp434`.`CUSTOMERS` (
`CUST_ID`,
`NAME` ,
`EMAIL` ,
`PASSWORD` ,
`ADDRESS`
)
VALUES (
?, ?, ?, ?, ?
)");
mysqli_stmt_bind_param($insertCust, 'sssss', $null, $name, $email, $password, $address);
$selectCust = mysqli_prepare($mysqli,
"SELECT *
FROM `CUSTOMERS`
WHERE `NAME` LIKE ?
AND `EMAIL` LIKE ?
AND `PASSWORD` LIKE ?
AND `ADDRESS` LIKE ?");
mysqli_stmt_bind_param($selectCust, 'ssss', $name, $email, $password, $address);
//Find num Rows to see if cust is preexisting
mysqli_stmt_execute($selectCust);
mysqli_stmt_store_result($selectCust);
$numRows = mysqli_stmt_num_rows($selectCust);
mysqli_stmt_close($selectCust);
//if preExisting gives Cust ID
//if not fetches custId
if ($numRows == 0)
{
mysqli_stmt_execute($insertCust);
mysqli_stmt_store_result($insertCust);
$custID = mysqli_stmt_insert_id($insertCust);
mysqli_stmt_close($insertCust);
}
else
{
print "hello1";
mysqli_stmt_execute($selectCust);
mysqli_stmt_bind_result($selectCust, $a,$b,$c,$d,$e);
print "hello You2";
while (mysqli_stmt_fetch($selectCust))
{
print "hello You3";
print "results are: $custID $b $c $d $e <br>";
}
mysqli_stmt_close($selectCust);
}
echo $custID;
echo $numRows;