Reputation: 27
hi guys i got problem in my code i don't know where come form this my code
<h1><?php echo $item["title"]; ?> </h1>
<table>
<tr>
<th>Catageory</th>
<td><?php echo $item["category"]; ?></td>
</tr>
<tr>
<th>Genre</th>
<td><?php echo $item["genre"]; ?></td>
</tr>
<tr>
<th>Format</th>
<td><?php echo $item["format"]; ?></td>
</tr>
<tr>
<th>Year</th>
<td><?php echo $item["year"]; ?></td>
</tr>
<?php
if(strtolower($item["category"]) == "books"){
?>
<tr>
<th>Authors</th>
<td><?php echo $item["authors"]; ?></td>
</tr>
<tr>
<th>Publisher</th>
<td><?php echo $item["publisher"]; ?></td>
</tr>
<tr>
<th>ISBN</th>
<td><?php echo $item["isbn"]; ?></td>
</tr>
<?php } ?>
And the error message,
and Iam sure all code are same i don't what's problem !!
Upvotes: 0
Views: 6847
Reputation: 27
my problem is solved
by replace
<td><?php echo $item["authors"]; ?></td>
to
<td><?php echo implode(",", $item["authors"]); ?></td>
Upvotes: 1
Reputation: 2168
You are trying to echo an array variable which is not right. Use the below debug code and you have to parse the array however you want.
Authors -> <?php echo "<pre>";print_r($item["authors"]);echo "<pre>"; ?>
Upvotes: 1
Reputation: 139
As per your image, you are trying to print string on line 58, but you are getting array from your resultant query. So try to var_dump($yourvar) and check that are you getting required string or an array
Upvotes: 1