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();
精彩评论