<?php
// post_view.php
require 'connection.php';
$id =$conn->lastInsertId('id');
$stmt = $conn->prepare('SELECT * FROM posts WHERE id = LAST_INSERT_ID(id) LIMIT 1');
$stmt->execute(array('id' => 'LAST_INSERT_ID(id)'));
while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
//$row is an array object? that has one array in index 0
print_r($row);
echo '<h2>'.$row[':title'].'</h2>';
//echo '<em>Posted '.date('F j<\s\up>S</\s\up>, Y', $row['date']).'</em><br/>';
echo nl2br($row[':body']).'<br/>';
echo '<a href="post_edit.php?id='.$id.'">Edit</a> | <a href="post_delete.php?id='.'id'.'">Delete</a> | <a href="index.php">View All</a>';
echo '<hr/>';
}
It all goes well right up untill i have to echo $row [':title'] and $row['body'], by using print_r($row); i've established that the row returned is an array object? with another array(only one, there is currently only one field in the database )but i cannot acess the contents in the array within the array? any ideas.