A question that usually would appear would be about an error relating to PDO shows up when you visit your freshly uploaded Vanilla 2.0.15 folder. It's obviously not a bug but I don't know where else to post this, but I originally had the question of "why am I getting an error about PDO?"
I wanted to help out by showing a small workaround. This happens because the PDO extension doesn't exist on the servers of your host. If your host, for some weird reason, denies enabling PDO, then there are workarounds available online. I managed to get
PHPPDO to do it.
The error looks like this:
Class 'PDO' not found in /vanilla/conf/config-defaults.phpI downloaded PHPPDO and created a folder called "phppdo" in the root of my Vanilla folder. I then opened /vanilla/library/core/class.router.php and added these lines of code to the top:
function db_connect($dsn, $username = '', $password = '', $driver_options = array(), $path = './phppdo')
{
$driver = strtolower(trim(substr($dsn, 0, strpos($dsn, ':'))));
if($driver && class_exists('PDO') && extension_loaded('pdo_' . $driver))
{
$class = 'PDO';
}
else
{
require_once($path . '/phppdo.php');
$class = 'PHPPDO';
}
return new $class($dsn, $username, $password, $driver_options);
}
try
{
$db = db_connect('mysql:dbname=', 'dbuser', 'dbpass', array(), $_SERVER['DOCUMENT_ROOT'].'/vanilla/phppdo');
} catch(PDOException $e)
{
die($e->getMessage());
}For the try statement, I added in my database info after each equals sign and the variables in $db. I'm not sure how to call the variables for $DatabaseName, $DatabaseUser, $DatabasePassword yet. If anyone knows how, please let me know.
After saving that file, I received another error like this one:
Cannot instantiate abstract class PDO in /vanilla/applications/dashboard/controllers/class.setupcontroller.php on line 120So I opened that file up and went down to line 120 and changed it up:
Find:
$Connection = new PDOChange that to:
$Connection = new PHPPDOThen I received the same error for /vanilla/library/database/class.database.php. The same fix applies here on line 56:
Change:
$this->_Connection = new PDOTo:
$this->_Connection = new PHPPDONow you can run Vanilla without PDO installed on your server.
Shadowdare | Computer Scientist | Sites: Livid Tech
2 · ·
Comments
- Spam
- Abuse
0 · Insightful Awesome LOL ·- Spam
- Abuse
0 · Insightful Awesome LOL ·Shadowdare | Computer Scientist | Sites: Livid Tech
- Spam
- Abuse
1 · Insightful Awesome LOL ·SQLSTATE[HY000] [1045] Access denied for user 'dbuser'@'localhost' (using password: YES)
what now ? ;)
- Spam
- Abuse
0 · Insightful Awesome LOL ·- Spam
- Abuse
0 · Insightful Awesome LOL ·$db = db_connect('mysql:dbname=', 'dbuser', 'dbpass', array(), $_SERVER['DOCUMENT_ROOT'].'/vanilla/phppdo');Add the dbname after the equals sign and change dbuser and dbpass. Also, make sure that the path to the phppdo is correct.
Shadowdare | Computer Scientist | Sites: Livid Tech
- Spam
- Abuse
0 · Insightful Awesome LOL ·I have just used these mods to run Vanilla2 on my MoWeS local host.
I was wondering if anyone has experienced any adverse affects from making these changes?
- Spam
- Abuse
0 · Insightful Awesome LOL ·Shadowdare | Computer Scientist | Sites: Livid Tech
- Spam
- Abuse
0 · Insightful Awesome LOL ·- Spam
- Abuse
0 · Insightful Awesome LOL ·$db = db_connect("mysql:host='your_hostname';dbname=", 'dbuser', 'dbpass', array(), $_SERVER['DOCUMENT_ROOT'].'/vanilla/phppdo');
- Spam
- Abuse
0 · Insightful Awesome LOL ·Parse error: syntax error, unexpected T_TRY, expecting T_FUNCTION
Any ideas?
- Spam
- Abuse
0 · Insightful Awesome LOL ·For v2.0.18.1 some of the info has changed:
in /vanilla/library/database/class.database.php - comment out line 55 ($this->IsPersistent ... - edit is now on line 58
in /vanilla/library/core/class.router.php - you enter the code AFTER the opening line <?php - you must enter the database name, user name, and password
in /vanilla/applications/dashboard/controllers/class.setupcontroller.php - edit is now on line 137
Also, if you muck up the install along the way, you may have to empty the database (drop all the tables) and delete the /conf/config.php file.
- Spam
- Abuse
0 · Insightful Awesome LOL ·For v2.0.18.2 some of the info has changed:
in /vanilla/library/database/class.database.php - comment out line 54 ($this->IsPersistent ... - edit is now on line 57 - also had to add
require_once($_SERVER['DOCUMENT_ROOT'].'/external/vanilla/phppdo'. '/phppdo.php');on line 29in /vanilla/library/core/class.router.php - you enter the code AFTER the opening line <?php - you must enter the database name, user name, and password
in /vanilla/applications/dashboard/controllers/class.setupcontroller.php - edit is now on line 137
Also, if you muck up the install along the way, you may have to empty the database (drop all the tables) and delete the /conf/config.php file.
I seem to get timeout errors though when trying it with remote sites (rather than a local test site)
- Spam
- Abuse
0 · Insightful Awesome LOL ·I now get this... Fatal error: Undefined class constant 'PDO::ATTR_DEFAULT_FETCH_MODE' in /home/emily/public_html/vanilla/phppdo/phppdo.php on line 361
Any advice?
- Spam
- Abuse
0 · Insightful Awesome LOL ·