I'm currently converting this piece of code from mysql to PDO:
$catquery = mysql_query("SELECT category, longdescription, locked,
catid, parentcatid, leveldown
FROM ".$tableprefix."fanfiction_categories
WHERE catid = '$catid'")
or die(_FATALERROR."Query: SELECT category, locked, catid, parentcatid, leveldown FROM ".$tableprefix."fanfiction_categories WHERE catid = '$catid'<br />Error: (".mysql_errno( ).") ".mysql_error( ));
$category = mysql_fetch_array($catquery);
I'm new to PDO but have been trying to learn what I can. This is what I came up with in PDO:
$db = new PDO('mysql:host='.$db_host.'; dbname='.$db_name, $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$catquery = $db->prepare("SELECT category, longdescription, locked, catid,
parentcatid, leveldown
FROM ".$tableprefix."fanfiction_categories
WHERE catid=:catid");
$stmt -> bindPARAM (':catid', $catid, PDO::PARAM_STR );
try {
$stmt->execute ();
echo "Sucess";
} catch (PDOException $e) {
echo $e->getMessage();
}
I can't get the bindPARAM portion correct, even after trying it in many forms. Is there something I'm overlooking? I'm a bit confused in regards to PDO, so it would be nice if someone could point out where I'm going wrong with this.