2

I have a very strange problem:

After deploying a small app to the prod server I am getting the following error:

Fatal error: Uncaught exception 'PDOException' with message 'Could not connect to     database.' in D:\inetpub\vhosts\DOMAIN\httpdocs\app\db\rb.php:194 
Stack trace: 
#0 D:\inetpub\vhosts\DOMAIN\httpdocs\app\db\rb.php(338): RedBean_Driver_PDO->connect() 
#1 D:\inetpub\vhosts\DOMAIN\httpdocs\app\db\rb.php(5674): RedBean_Driver_PDO->setDebugMode(true, Object(RedBean_Logger_Default)) 
#2 D:\inetpub\vhosts\DOMAIN\httpdocs\app\db\test.php(7): RedBean_Facade::debug(true) 
#3 {main} thrown inD:\inetpub\vhosts\DOMAIN\httpdocs\app\db\rb.php on line 194

I double checked host, user, db name and password and everything looks good.

I even created 2 php scripts:

//this one throws the error

require('rb.php');
R::setup('mysql:host=localhost;dbname=DBNAME', 'DBUSER','DBPASS'); //mysql
R::debug(true);
$testRecord = R::load('test', 1);
echo $testRecord->name;

//this one works fine

mysql_connect('localhost', 'DBUSER', 'DBPASS') or die(mysql_error());
mysql_select_db('DBNAME') or die(mysql_error());
$result = mysql_query("SELECT * FROM test")
or die(mysql_error());  
$row = mysql_fetch_array( $result );
echo "Name: ".$row['name'];

what am I missing here? Please note that both scripts work fine on localhost. Also, localhost in a Linux machine while PROD is Windows. But why would that matter?

3 Answers 3

4

So the problem was that the windows server does not have PDO mysql drivers installed.

1
  • Thanks! I was having the same problem.
    – kralyk
    May 22, 2014 at 12:36
4

In linux ubuntu: sudo apt-get install php5-sqlite

Then restart your apache (sudo /etc/init.d/apache2 restart)

1

I received this same error, but running Ubuntu 16.04 had to change to:

sudo apt-get install php7.0-sqlite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.