Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Fatal error: Call to undefined method PDOStatement::fetch_assoc()

$
0
0
I keep receiving the error message:

Fatal error: Call to undefined method PDOStatement::fetch_assoc() in index.php on line 16 Call Stack: 0.0001 644064 1. {main}() index.php:0



for this piece of code. How do I go about resolving it?

<?php 
session_start();
require_once("../resources/php/connection.php");

// use quote or prepared statements to prevent from 
// SQL injection attacks!
$pmname = $pdo->quote($_SESSION['pmname']);
$sql = "SELECT * FROM pm_user WHERE name=$pmname";

$result = $pdo->query($sql);
if($result === FALSE) {
    echo 'oops! the query failed! ';
    print_r($pdo->errorInfo());
}

$row = $result->fetch_assoc();

if($row) {
    echo $row['img'];
} else {
    echo 'the query return no records :(/>/>';
}
?>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>