I have this code which retrieves data from a MySql database:
<?php
$con= mysqli_connect("localhost","root","","darrenvellaedp2");
$query = mysqli_query($con,"SELECT postTitle, pContent FROM tbl_posts WHERE userID = '2'  ");
while($rows = mysqli_fetch_array($query))
{
    $title = $rows['postTitle'];
    $content = $rows['pContent'];
}
?>
I'm getting these errors:
Notice: Undefined variable: title in C:\xampp\htdocs\WSSA1S1\index.php on line 48
Notice: Undefined variable: content in C:\xampp\htdocs\WSSA1S1\index.php on line 50
Before you tell me that this problem has already been answered in this forum and you can use isset() to solve the problem. I know, I tried but eighter I'm not implementing it right or it just can't work with my code.
I've saw this post:
PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"
It's not working for me.. I did has he told in the answer but I keep getting the errors.
I'm using the variables here:
<article class="contentbox1">
            <div class="articleHEADER">
                    <!--<h2>Welcome!</h2>-->
                    <h2><?php echo "$title"?></h2>
            </div>
                <p><?php echo "$content"?></p>
                <footer>
                    <p class="post-info">This post is written by admin</p>
                </footer>
Please someone help!
 
     
     
    