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

i m passing db connection and entry id to function and function returning mein one when i check with print_r
$e is not returning please help me out

here is the function

function retrieveEntries($db,$id=NULL)

        $sql ="SELECT title,entry FROM entries WHERE id =? LIMIT =1";

        $sql="Select id,title From entries ORDER BY created DESC";

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

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

    array_push($e, $fulldisp);

    return  $e;

Recommended Answers

All 3 Replies

try to check if the query is returning any rows

Well to solve problems like this you are to apply some nice clean debugging approach.

You are passing your connection object and an ID.

before this statement below.


I would advice you perform a simple check on the two parameters that you are passing.

First is your connection parameter. check if it is actually active. you can use the isset() method of php to check in an if statement.

Secondly check the content of the $id. Try to echo the content to see what is there.

remember if you pass an invalid id or an id that does not exist you would have an empty resultset.

Be a part of the DaniWeb community

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