一直有一些问题,与此代码,由于某种原因,它可以在一个PHP脚本,但是这一次拒绝工作,我不知道,为什么,因为我敢新的PHP和学习POST和其他的东西,这是工作正常,但我不明白是什么问题,因为PDO是每个其他PHP文件相同,他们工作正常。语法错误,意外“:”在线56
我已经得到的错误:
语法错误,意外 ':' 上线56(又名:CATID BindParam)
和我的代码:
<?PHP
if (!defined('init_executes'))
{
header('HTTP/1.0 404 not found');
exit;
}
$CORE->loggedInOrReturn();
//prepare multi errors
$ERRORS->NewInstance('forums_forum_forum');
//bind on success
$ERRORS->onSuccess('Forum Sucessfully Created..', '/index.php?page=forums');
$name1 = (isset($_POST['name']) ? $_POST['name'] : false);
$desc1 = (isset($_POST['desc']) ? $_POST['desc'] : false);
$catoid = (isset($_POST['catid']) ? $_POST['catid'] : false);
$rrtct1 = (isset($_POST['rrtct']) ? $_POST['rrtct'] : false);
if (!$name)
{
$ERRORS->Add("Please enter a Forum title.");
}
if(!$catid)
{
$ERRORS->Add("Please enter a Destination Catagory");
}
$ERRORS->Check('/index.php?page=forums');
####################################################################
## The actual script begins here
//Determine the Position within the Category
$res2 = $DB->prepare("SELECT `position` FROM `wcf_categories` WHERE id =:catids ORDER BY `position` DESC LIMIT 1");
$res2->bindParam(':catids', $catoid, PDO::PARAM_INT);
$res2->execute();
if ($res2->rowCount() > 0)
{
$row2 = $res2->fetch();
$position = $row2 + 1;
unset($row2);
}
else
{
$position = 0;
}
unset($res2);
$insert = $DB->prepare("INSERT INTO wcf_forums (category, name, description, position, required_rank_create_thread) VALUES (:catid, :name, :desc, :pos, :rank_thread);");
$insert->bindParam(':catid', $catoid, PDO::PARAM_INT);
$insert->bindParam(':name', $name1, PDO::PARAM_STR);
$insert->bindParam(':desc', $desc1, PDO::PARAM_STR);
$insert->bindParam(':pos', $position, PDO::PARAM_INT);
$insert->bindParam(':rank_thread', $rrtct1, PDO::PARAM_INT);
$insert->execute();
if ($insert->rowCount() < 1)
{
$ERRORS->Add("The website failed to insert the forum record.");
}
else
{
unset($insert);
$ERRORS->triggerSuccess();
}
unset($insert);
####################################################################
$ERRORS->Check('/index.php?page=forums');
exit;
你刚刚在这个语句中错过了'单引号'$ res2-> bindParam(':catids,$ catoid,PDO :: PARAM_INT);' –
你在这一行中缺少一个结束单引号(''') :'$ res2-> bindParam(':catids,$ catoid,PDO :: PARAM_INT);'*编辑:*该死,太迟:) – Hexaholic
你为什么修复你的问题中的代码?它是否解决了实际问题? –