Hello, I’m trying to output a JSON format of the selected records in my table. However, so far my only output is:
[php]string(3) “the” string(81) “SELECT ID
, NewsStory
, Summary1
, Summary2
FROM Articles
WHERE Tags
= ?”[/php]
I am unsure where i have gone wrong and would be very appreciative of any help.
[php] <?php
//Open a new connection to the MySQL server
$mysqli = new mysqli(‘localhost’,‘createyo_james’,‘password’,‘createyo_TestDatabase’);
//Output any connection error
if ($mysqli->connect_error) {
die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
}
$myArray = array();
$Tags = $_GET["Tags"];
var_dump($_GET["Tags"]);
$query = "SELECT `ID`, `NewsStory`, `Summary1`, `Summary2` FROM `Articles` WHERE `Tags` = ?";
$statement = $mysqli->prepare($query);
var_dump($query);
//bind parameters for markers, where (s = string, i = integer, d = double, b = blob)
$statement->bind_param('s', $Tags);
if($statement->execute()){
$statement -> execute();
$result = $statement -> get_result();
while($row = $result -> fetch_assoc()) {
$output[]= $row;
}
print(json_encode($output));
$result->close();
$mysqli->close();
}else{
die('Error : ('. $mysqli->errno .') '. $mysqli->error);
}
$statement->close();
?>[/php]
Thanks, James.