/    Sign up×
Community /Pin to ProfileBookmark

PHP PDO Problems with bindParam, stored procs and in/out variables

Hi all,

Im having problems with php database objects and difficulty with bindParam in particular.

The Following works fine.

[code=php]
$data = $this->DBH->query(“call insert_lead_details(‘fred’, ‘flinstone’, @response);”)->fetchAll(PDO::FETCH_ASSOC);
$total_count = $this->DBH->query(“select @response;”)->fetchAll(PDO::FETCH_ASSOC);

print_r($data);
echo ‘<br />’;
print_r($total_count);
[/code]

But when I try using the following syntax i get nothing at all – no DB update and no error (or error code of 00000)

[code=php]
$stmt = $DBH->prepare(“call insert_lead_details(:visitorID,:firstname,:response);”);

$D1 = ‘fred’;
$D2 = ‘flinstone’;

$stmt->bindParam(“:visitorID”, $D1) ;
$stmt->bindParam(“:firstname”, $D2);
$stmt->bindParam(“:response”, $response , PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 50);
$stmt->execute();

print $response;
[/code]

From the tuts I’ve read my syntax seems alright, I’ve tried with and without specifying the parameter type and length and im still stuck. Can anyone see what I’ve missed.

Thanks in advance!

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 31.2010 — Off-hand I don't know what's wrong (I've not used PDO much at all), but do you get any kind of errors? (Maybe make sure all error-reporting is on and display_errors enabled?) It may also help to check the results of bindParam() and execute(), and if false, use [url=http://www.php.net/manual/en/pdostatement.errorinfo.php]errorInfo[/url]() to get some error info.
×

Success!

Help @patnz 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...