-2

I am having getting my query to display results, I have ran the exact same query locally in mySQL and I get the desired result but when it is executed through the following code nothing happens.

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

I cannot understand why I get no results I am getting the Connected Successfully message but no actual values are returned.

Lewis M Hackfath
  • 131
  • 5
  • 17

1 Answers1

2

You need to execute() a prepared statement to make it do anything.

$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();
Darwin von Corax
  • 5,201
  • 3
  • 17
  • 28
  • There's nothing "to" prepare in their question, so all they really needed to do was use `->query()` instead of `->prepare()`. – Funk Forty Niner Feb 19 '16 at 02:14
  • They've commented out a call to `bind_param()`; I would assume they want to use it again once the prepared statement is returning data. – Darwin von Corax Feb 19 '16 at 02:16
  • @Fred-ii- Not really. As I read it, the objective was to figure out why the prepared statement wasn't working. Commenting out the `bind_param()` call was just a case of eliminating a variable factor from the experiment. – Darwin von Corax Feb 19 '16 at 02:22