1

I am trying to add the values of the below prepared statement to array (as I will use this array later in another prepared statement). but the result when I echo the array is "Array" without any values.

What is missing?

the php code:

<?php
$mysqli = new mysqli("x", "y", "z", "w");
$coresite = $_POST["selectedcoresite"];
$rowx = $_POST["selectedrow"];
$colx = $_POST["selectedcolumn"];
$directionx = $_POST["selecteddirection"];
$NodeID = [];

if($stmt = $mysqli->prepare("SELECT DISTINCT idNode FROM NodePorts WHERE (SiteName=? AND Row=? AND Col=? AND Direction=?)"))
{
$stmt->bind_param("ssss", $coresite, $rowx, $colx, $directionx);
$stmt->execute();
$stmt->bind_result($ID);
while ($stmt->fetch()) 
{
array_push($NodeID, $ID);
}
$stmt->close();
}
else{
$mysqli->close();    
}

echo($NodeID);
?>
1
  • 2
    Well, yes. If you echo an array, you get "Array". You can use var_dump for example to output what the array looks like. I'm not sure what you're actually wanting to do though. Commented May 9, 2016 at 18:09

1 Answer 1

1

This will display the whole array. var_dump($NodeID);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.