我很确定我只需要一个好的 ol` 时尚大脑检查。我从未见过如此愚蠢的问题,我敢肯定我只是错过了一些愚蠢的事情。
索引.php
<?
require('lib/conf.php');
/* bunch of code here */
echo get_user('username',$_SESSION['uid']);
lib/conf.php
<?
/* bunch of secret stuff here */
$dbcon = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
////////////
//
// Includes / Requirements
//
////////////
include('functions/user.functions.php');
函数/user.functions.php
<?
function get_user($dvar,$uid){
$psql = $dbcon->prepare("SELECT :dvar FROM ls_users WHERE uid=:uid");
$dbcon->beginTransaction();
$psql->execute(array(":dvar"=>$dvar,":uid"=>$uid));
foreach($psql as $row){ return $row[$dvar]; }
}
但是尝试做这样一个简单的事情,我继续得到:
Undefined variable: dbcon in <b>/home/lodestar/public_html/lib/functions/user.functions.php</b> on line <b>10</b>
Call to a member function prepare() on a non-object in <b>/home/lodestar/public_html/lib/functions/user.functions.php</b> on line <b>9
所以,现在我觉得我快疯了,请你检查一下我的大脑并告诉我我错过了什么吗?
笔记
错误的行号不会反映示例代码中的正确行号