Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Fatal error: Call to undefined method DB_Error::setFetchMode

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
rekabis
Smarty n00b


Joined: 17 Jul 2007
Posts: 2

PostPosted: Tue Jul 17, 2007 11:38 pm    Post subject: Fatal error: Call to undefined method DB_Error::setFetchMode Reply with quote

I am having a serious problem with a site I am currently designing. That, and a conundrum - code works on one site, but fails on another, despite both sites being simple and identical (in terms of underlying technology)!!

I am following the suggestions given on this site:
{link removed, unable to post link as forum rejects posts with links, please PM for link to reference... gotta love this forum’s usability!!!}

and I have created the following code for both sites:
Code:
<?php
require_once('Smarty.class.php');
require_once('DB.php');
error_reporting(E_ALL - E_NOTICE);
$web_root = '{link removed due to brain-dead usability in this forum}';
$app_root = '/home/cgmi/';
$pear = $app_root.'smarty/';
$dsn = "mysql://username:password@localhost/database";
$db = DB::connect($dsn);
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$db->setOption('optimize', 'portability');
$t = new smarty;
$t->template_dir = $app_root.'public_html/tpl/';
$t->compile_dir = $app_root.'smarty/templates/www/';
$t->cache_dir = $app_root.'smarty/cache/';
$t->config_dir = $app_root.'smarty/configs/';


With the second site, I get the following error:
Code:
Fatal error: Call to undefined method DB_Error::setFetchMode() in /home/cgmi/smarty/www.php on line 10

but the first site functions flawlessly!!

The only way to get rid of this error is to comment out (remove) line 10, at which time it promptly complains about line 11 in the same way. Removing both lines prevents database access, as every $db->getAll() throws an error.

Both sites are hosted on the same host, under the same reseller account, and on the same machine (they have the same IP address). Both make use of PHP5.2.2, and identical php.ini & .htaccess files. I even cut-and-paste the entire smarty directory, making changes only to www.php as needed (the absolute paths from the root of the server, etc.). And yet, something keeps on screwing up. Suggestions?
Back to top
View user's profile Send private message
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Wed Jul 18, 2007 7:47 am    Post subject: Reply with quote

My first suggestion is not trolling around in a forum you are new to and want its users help from. You may not post links in your very first post due to security reasons in this forum. As you might know, security and usability are often two competing quality features which often can't be fully satisfied at the same time.

Back to your problem:
The error message indicates, that $db is of the type DB_Error which indicates, that DB::connect($dsn); has returned no valid DB Object but some kind of an error object. Check your database connection on the host the script doesn't work. BTW, reliabilty also is an important software quality feature, so you might consider checking the $db object for it's validity and display a user-friendly error message, since this affects your software's usability.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
rekabis
Smarty n00b


Joined: 17 Jul 2007
Posts: 2

PostPosted: Wed Jul 18, 2007 6:18 pm    Post subject: Reply with quote

Celeb wrote:
You may not post links in your very first post due to security reasons in this forum.

I would really like to learn about these reasons. The only security benefit I could immediately see would be to avoid spammers and bots (automated posting software wouldn’t be able to get past the first post). However, the forum itself has a sign-up verification scheme in place, and automated posting software could always be re-configured to create a random post (or one without a link) the first time it accessed a forum.

Frankly, this is the first forum I have ever come across that has a link restriction like this. It is capricious, and IMHO rather useless.

Celeb wrote:
Back to your problem:
The error message indicates, that $db is of the type DB_Error which indicates, that DB::connect($dsn); has returned no valid DB Object but some kind of an error object. Check your database connection on the host the script doesn't work.


The problem may very lie with my host, and how they have configured their servers.

I have destroyed and re-created the database user/pass several times, just to make sure it was done right. Nothing. Then I created another user, completely at random, with the exact same password as the first user (to rule out a password that corrupts the access string). Bingo. It worked, and everything was up and running flawlessly. I removed the first user/pass that didn’t work, and boggo; database access failed again. It was a very big Whisky Tango Foxtrot moment, I’ll tell ya.

It seems that two user/pass need to be assigned to the DB, in order for the web site to be able to access the DB, even though the PHP script only uses one of the two. Strange.

The other site (that works properly) also has multiple user/pass assigned to each DB, but that was only for logging purposes (I have multiple DB’s, and I wanted phpMyAdmin to use a separate user/pass than the PHP scripts). Since I was only going to have one DB with this site, I didn’t think I needed to be as anal in terms of tracking DB access.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Jul 19, 2007 9:17 am    Post subject: Reply with quote

Hi.

Bingo on the spam/bot problem. Actually, the link limitation was a default in the mod that was installed for this forum. To be honest, the limitation is a pita for users but without it, we were suffering from unwanted noise. I think the main benefit of the system is that is requires little admin effort -- which I for one consider a boon Wink

On to more important things: I never see your code calling DB_Error::setFetchMode(). Seems perhaps that some more code needs to be shown for a reproducing case?
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP