我想从我的数据库中选择数据,它在localhost中运行得很好但是当我上传它时显示此错误Strict Standards: Only variables should be passed by reference in /home/account/public_html/cosrc/config.php on line 28
在第28行,我想使用client ip在where子句中选择,所以我将bindParam
更改为bindValue
,我在第23行得到了相同的错误,第23行的第23行输出应该像这个data1, DATA2,DATA3,等...
<?php
//Here i select from main content
$CheckOrSeesion = new DBController();
$CheckOrSeesion->prepare("SELECT * FROM jailorgname j INNER JOIN users u ON j.jailorgnowner = u.username WHERE orgname = :checkOName LIMIT 1");
$CheckOrSeesion->bind(':checkOName', $currentBas);
$CheckOrSeesion->execute();
$OrgFound = $CheckOrSeesion->getOne();
$CheckOrSeesion->free();
if($OrgFound){
$orgname = $OrgFound->orgname;
$jailorgnowner = $OrgFound->jailorgnowner;
$OrgDescription = $OrgFound->OrgDescription;
$OrgUphoto = $OrgFound->photo;
$OrgUjlikes = $OrgFound->jlikes;
$OrgUjviewers = $OrgFound->jviewers;
$Orgratstar = $OrgFound->ratstar;
$Orgjaildate = $OrgFound->jaildate;
$Orgjtags = $OrgFound->jtags; // Line 23
}
//Here i check if user ip have view the post
$db_conn = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME,DB_USERNAME,DB_PASSWORD);
$db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$Checkviewed = $db_conn->prepare("SELECT COUNT(uip) FROM jailviewmap WHERE uip = :uip AND jailname = :jailname LIMIT 1");
$Checkviewed->bindValue(':uip', getUserIP()); //Line 28
$Checkviewed->bindParam(':jailname', $currentBas);
$Checkviewed->execute();
$yesvi = $Checkviewed->fetchColumn();
if(empty($yesvi) OR $yesvi == 0){
//Here if not viewed i insert it in view map
$db_conn = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME,DB_USERNAME,DB_PASSWORD);
$db_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$addviewMap = $db_conn->prepare("INSERT INTO jailviewmap(jailname,uip)VALUES (:jailname,:uip)");
$addviewMap->bindParam(':jailname',$currentBas);
$addviewMap->bindParam(':uip', getUserIP());
$addedMap = $addviewMap->execute();
}
?>
请有一个更好的方法来减少执行数据库查询我也会感激,如果我可以使用我的单选与联盟来检查我想要的