problem with fetch
Posted: Sun Apr 22, 2012 11:34 pm
Hi
I want to make a CMS,but in my first test,I recieved following error:
Fatal error: Call to a member function fetch() on a non-object in C:\wamp\www\cms\ww.incs\basics.php on line 23
basic.php:
I use wampserver in localhost, php_pdo and php_pdo_mysql extensions are enable! please help me.
Thanks
I want to make a CMS,but in my first test,I recieved following error:
Fatal error: Call to a member function fetch() on a non-object in C:\wamp\www\cms\ww.incs\basics.php on line 23
basic.php:
Code: Select all
<?phpsession_start();
function __autoload($name) {
require $name . '.php';
}
function dbInit(){
if(isset($GLOBALS['db']))return $GLOBALS['db'];
global $DBVARS;
$db=new PDO('mysql:host='.$DBVARS['hostname'].';dbname='.$DBVARS['db_name'],$DBVARS['username'],$DBVARS['password']);
$db->query('SET NAMES utf8');
$db->num_queries=0;
$GLOBALS['db']=$db;
return $db;
}
function dbQuery($query){
$db=dbInit();
$q=$db->query($query);
$db->num_queries++;
return $q;
}
function dbRow($query) {
$q = dbQuery($query);
return $q->fetch(PDO::FETCH_ASSOC);
}
define('SCRIPTBASE', $_SERVER['DOCUMENT_ROOT'].'cms/' );
require SCRIPTBASE . '.private/config.php';
if(!defined('CONFIG_FILE'))define('CONFIG_FILE',SC RIPTBASE.'.private/config.php');
set_include_path(SCRIPTBASE.'ww.php_classes'.PATH_ SEPARATOR.get_include_path()); Thanks