Jump to content

PDO query


doddsey_65

Recommended Posts

in my attempts at PDO i seem to have gone wrong here. perhaps someone can help:

 

$query = "SELECT *
                FROM ".TBL_PREFIX."users
                WHERE u_uid=$uid";
        $stmt = $link->query($query);
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        
        foreach($result as $key => $val)
        {
            echo $key.' - '.$val.'<br />';
        }

 

this is the error:

 

Fatal error: Call to a member function fetch() on a non-objec

 

$link = new PDO("mysql:host={$settings['hostname']};
                        dbname={$settings['database']}",
                            $config['database']['username'],
                            $config['database']['password']
                            );

Link to comment
https://forums.phpfreaks.com/topic/225704-pdo-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.