/    Sign up×
Community /Pin to ProfileBookmark

Fatal error: Call to a member function setFetchMode() on boolean

HI ALL,

IM TRYING TO PASS A STORED PROCEDURE IN MY PHP CODE AND IM GETTING THE ERROR AS
Fatal error: Call to a member function setFetchMode() on boolean.PLEASE LET ME KNOW WHY IM GETTING THIS ERROR:

PFB MY SP;

DELIMITER $$

CREATE PROCEDURE INCIDENT()

BEGIN

DECLARE NAMEE VARCHAR(10);

DECLARE CUR1 CURSOR for SELECT * FROM TEMP;

open CUR1;

read_loop: LOOP

FETCH CUR1 INTO NAMEE;
SELECT NAMEE;

insert into incident values ((select distinct(NAME) from IMDETAILS where NAME=NAMEE),

(SELECT COUNT(*) FROM IMDETAILS WHERE NAME=NAMEE AND RESOLVED_DATE=(SELECT CURDATE()) AND STATUS=’RESOLVED’),

(SELECT COUNT(*) FROM IMDETAILS WHERE NAME=NAMEE AND RESOLVED_WEEK = WEEK(CURDATE()) AND STATUS=’RESOLVED’),

(SELECT COUNT(*) FROM IMDETAILS WHERE NAME=NAMEE AND RESOLVED_MONTH=(SELECT DATE_FORMAT(NOW(),’%M’)) AND STATUS=’RESOLVED’),

(SELECT POINTS FROM POINT WHERE IMCOUNT<=(SELECT COUNT(*) FROM IMDETAILS WHERE NAME=NAMEE AND RESOLVED_MONTH=(SELECT DATE_FORMAT(NOW(),’%M’))
AND STATUS=’RESOLVED’ )));

SELECT * FROM INCIDENT ORDER BY POINTS;

END LOOP;
CLOSE CUR1;

END $$;

DELIMITER;

[U]here IS MY PHP CODE[/U]

<?php
require_once ‘DBconfig.php’;
try {
$pdo = new PDO(“mysql:host=$host;dbname=$dbname”, $username, $password);

[U]hERE IM CALLING THE SP INCIDENT
[/U]

[COLOR=”#FFFF00″] $sql= ‘call incident()’;
[/COLOR]

$q = $pdo->query($sql);

$q->setFetchMode(PDO::FETCH_ASSOC);

} catch (PDOException $e) {
die(“Could not connect to the database $dbname :” . $e->getMessage());
}
?>

<!DOCTYPE html>
<html>
<style>
table,th,td {
border : 1px solid black;
border-collapse: collapse;
}
th,td {
padding: 5px;
}

tr:nth-child(even){background-color: #f2f2f2}
a:link {
text-decoration: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #e7e7e7;
background-color: #f3f3f3;
}
li {
float: left;
}
li a {
display: block;
color: #666;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #ddd;
}
li a.active {
color: white;
background-color: #4CAF50;
}

</style>
<body>
<ul>
<li><a class=”active” href=”D:wamp64wwwIncident.php”>INCIDENT</a></li>
<li><a href=”D:wamp64wwwProblem.php”>PROBLEM</a></li>
<li><a href=”D:wamp64wwwChange.php”>CHANGE</a></li>
</ul>
<div id=”container”>
<h1>Resolved</h1>
<table class=”table table-bordered table-condensed”>
<thead>
<tr>
<th>Name</th>
<th>DAILY COUNT</th>
<th>WEEKELY COUNT</th>
<th>MONTHLY COUNT</th>
<th>POINTS</th>
</tr>
</thead>
<tbody>
<?php while ($row = $q->fetch()): ?>
<tr>
<td><?php echo htmlspecialchars($row[‘NAME’]) ?></td>
<td><?php echo htmlspecialchars($row[‘DAILYCOUNT’]); ?></td>
<td><?php echo htmlspecialchars($row[‘WEEKLYCOUNT’]); ?></td>
<td><?php echo htmlspecialchars($row[‘MONTHLYCOUNT’]); ?></td>
<td><?php echo htmlspecialchars($row[‘POINTS’]); ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>

</body>
</div>
</html>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 10.2016 — Possibly:
[code=php]
$sql = 'select incident()';

// and then test that it worked:
$q = $pdo->query($sql);
if($q == false) {
// maybe some debug code for now?
die('<pre>'.var_export($pdo->errorInfo(),1),1).'</pre>');
}
[/code]


PS: Using this forum's [U]bbcode tags[/U] such as the [noparse][code=php]...[/code][/noparse] tags can help us help you. Also, it's considered bad etiquette to SHOUT AT US IN ALL CAPS.
×

Success!

Help @RMP spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...