1 Replies - 801 Views - Last Post: 01 February 2013 - 07:21 PM Rate Topic: -----

#1 jeansymolanza  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 77
  • Joined: 20-February 08

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

Posted 01 February 2013 - 06:16 PM

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 :(/>/>';
}
?>


Is This A Good Question/Topic? 0
  • +

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

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

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

Posted 01 February 2013 - 07:21 PM

Too much is wrong to try to correct here. You should read/study this.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1