开发者

PDO bind parameter fails silently on staging and hosting server

开发者 https://www.devze.com 2023-02-07 04:07 出处:网络
I am using WindowsXP machine for the PHP pages I am developing. I am using PDO to connect to MySQL backend. In my development environment it works just fine but it silently stops processing in my Cent

I am using WindowsXP machine for the PHP pages I am developing. I am using PDO to connect to MySQL backend. In my development environment it works just fine but it silently stops processing in my CentOS 5.5 testing server. After some debugging, I found that it stops exactly at '$stmt->bindParams' section.

My statement is as follows:

$stmt = $dbh->prepare('SELECT * FROM MEMBERS WHERE ID=:what');

echo 'statement prepared'; //deb开发者_C百科ug

$stmt->bindParam('what', $enteredid);

echo 'parameters bound'; //debug

also tried

$stmt->bindParam('what', $enteredid, PDO::PARAM_STR, 255);

both works in my development machine but it stops in my test server.

I can only see 'statement prepared' and nothing happens.

Also tried the page in hosting environment. Same thing happens.


When you call bindParam() don't you need to pass ':what' as the placeholder to bind to instead of 'what'? Not sure why this would work on Windows and not Linux though...


Old, but someone might find this useful

The correct code is:

$stmt = $dbh->prepare('SELECT * FROM MEMBERS WHERE ID=:what');

echo 'statement prepared'; //debug

$stmt->bindValue(':what', $enteredid);

echo 'parameters bound'; //debug

$stmt->execute();
0

精彩评论

暂无评论...
验证码 换一张
取 消