简体   繁体   中英

Prepare Statement doesn't return anything

Do you know what could be the problem? The query is working fine. I tried it in PHPMyAdmin and it returned everything I expected except taskTime which isn't empty. It gives the correct number:

在此处输入图片说明

$mysqli = new mysqli($SQLhost, $SQLusername, $SQLpassword, $SQLdatabase);

$stmt = $mysqli->prepare("SELECT Account.accountEmail, Account.accountUsername,Task.taskName,Task.taskDescription,Task.taskTime FROM Account INNER JOIN Task ON Task.accountId=Account.accountId WHERE taskId=?");
$stmt->bind_param('i', $taskId);

$stmt->execute();

$stmt->bind_result($accountEmail,$accountUsername,$taskName,$taskDesc,$taskTime);

echo("Account Email: " . $accountEmail . " | Account Username: " .$accountUsername . " | Task Name: " . $taskName . " | Task Desc: " . $taskDesc . " | Task Time: " . $time . " | Task Id: " . $taskId);

Working code:

$mysqli = new mysqli($SQLhost, $SQLusername, $SQLpassword, $SQLdatabase) or die("Error " . mysqli_error($mysqli));


$stmt = $mysqli->prepare("SELECT Account.accountEmail, Account.accountUsername,Task.taskName,Task.taskDescription,Task.taskTime FROM Account INNER JOIN Task ON Task.accountId=Account.accountId WHERE taskId=?");
$stmt->bind_param('i', $taskId);

$stmt->execute();

$stmt->bind_result($accountEmail,$accountUsername,$taskName,$taskDesc,$taskTime);
$stmt->fetch();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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