我正在查询显示结果,我在mySQL中本地运行了完全相同的查询,我得到了所需的结果但是当通过以下代码执行时没有任何反应。
$JobID = '3214.GF.010.J45.TEA';
$ProjectID = '3214';
$conn = new mysqli ($server,$username,$password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully <br>";
$stmt = $conn->prepare('Select jmpPartShortDescription, ujmpLevel, ujmpRoom, jmpClosed from Inf_Jobs');
//$stmt->bind_param('ss',$JobID,$ProjectID);
$stmt -> bind_result($Description,$Level,$Room,$Closed);
$stmt -> fetch();
$stmt -> close();
$conn -> close();
echo $Description .$Level .$Room .$Closed;
我无法理解为什么我没有得到任何结果我收到了Connected Successfully消息,但没有返回实际值。
答案 0 :(得分:2)
你需要execute()
准备好的声明才能让它做任何事情。
$stmt = $conn->prepare('Select jmpPartShortDescription, ujmpLevel, ujmpRoom, jmpClosed from Inf_Jobs');
//$stmt->bind_param('ss',$JobID,$ProjectID);
$stmt->execute(); // <- this is what does the work
$stmt -> bind_result($Description,$Level,$Room,$Closed);
$stmt -> fetch();