i having these two annoying errors plz help me out how to fix these.

Warning: array_push() expects parameter 1 to be array, boolean given in D:\xampp\htdocs\simple_blog\inc\functions.inc.php on line 31

Warning: array_pop() expects parameter 1 to be array, boolean given in D:\xampp\htdocs\simple_blog\index.php on line 20

<?php 
include_once 'inc/functions.inc.php';
include_once 'inc/db.inc.php';

$db = new PDO(DB_INFO,DB_USER,DB_PASS);

$id = (isset($_GET['id'])) ? (int) $_GET['id']:NULL;

$e = retrieveEntries($db,$id);

$fulldisp =array_pop($e);

$e =sanitizeData($e);

if ($fulldisp ==1)
{
?>
  <h2> <?php echo $e['title']?></h2>
    <p><?php echo $e['entry']?></p>    
<?php }

?>

......
<?php
function retrieveEntries($db,$id=NULL)
{
    if(isset($id))
    {
        $sql ="SELECT title,entry FROM entries WHERE id =? LIMIT =1";
        $stmt=$db->prepare($sql);
        $stmt->execute(array($_GET['id']));
        $e=$stmt->fetch();
        $fulldisp=1;        
    }
    else
    {
        $sql="Select id,title From entries ORDER BY created DESC";

        foreach ($db->query($sql) as $row)
        {
            $e[] =array($row['id'],$row['title']);
        }
        $fulldisp = 0;
        if(!is_array($e))
        {
            $fulldisp =1;
            $e = array('title'=>'No Entrie Yet',

                    'entry'=>'<a href="/admin.php">Post an entry!</a>' 
                    );
        }

    }
    array_push($e, $fulldisp);

    return  $e;
}
function sanitizeData($data)
{
    if(!is_array($data))
    {
        return strip_tags($data,"<a>");
    }
    else
    {
        array_map('sanitizeData',$data);
    }
}
?>

debug it with var_dump($e);

yeah i debug it and its giving boolean false means no row returned

false means no row returned

That is correct. That usually means an error in your query. In this case, on line 30, change LIMIT =1 to LIMIT 1

cut the crap look at your $e array indexes. kindly place which array key index of your $e that your $fulldisp value should insert it.
The reason:

$e has an array index holding $row[] which has 2 array index keys.

in this manner it will look like $e=((x,y),(x,y)...,(x,y))

your objective is to set value in an element of $e. but $e's supposed to be element is also an array

since you used array_push() you need $row array instead of $e array as the array holder.

array_push can only handle one array index per transaction of value at a time. it's just like you finding the cabinet inside a cabinet so you could insert the file. that's what your code is

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.