Been struggling at this for a couple of hours now. Can anybody point out where I'm going wrong.
The first error I get is:
Fatal error: Call to undefined method PDO::rowCount() in
pm_wall.php on line 8
Call Stack: 0.0000 643680 1. {main}()
index.php:0 0.0015 662904 2.
include('pm_wall.php')
index.php:117
The second error I get is:
Warning: Invalid argument supplied for foreach() in pm_wall.php on line 19
Call Stack:
0.0000 643296 1. {main}() index.php:0
0.0015 649864 2. include(index.php:117
How do I go about resolving this? Here is my code below:
$sql = "SELECT * from pm_msg";
$result = $pdo->query($sql);
if($pdo->rowCount() > 0 && !empty($result)) // first error occurs here
{
foreach ($result as $row)
{
$user_id = $row['user_id'];
echo '<div id="content">
<div class="stbody">
<div class="stimg">';
// set profile picture
$sql = "SELECT img FROM pm_user WHERE id=$user_id";
$result = $pdo->query($sql);
foreach ($result as $row) // second error occurs here
{
echo $row['img'];
}
echo '<div id="stexpandbox"><div></div>';
echo '</div></div></div></div>';
}
}
else
{
echo 'Wanna be starting soemthing?';
}