0
votes

I'm having trouble with a CakePHP website. I've dropped my app directory into a staging folder so it's a duplicate of the live site. So the structure looks like this:

app
    config
    ...
    webroot
cake
    config
    ...
    tests
docs
staging
    app
        config
        ...
        webroot
    vendors
vendors

I've set the CAKE_CORE_INCLUDE_PATH constant in /staging/app/webroot/index.php to the root directory where my cake folder is, and set my database settings in /staging/app/config/database.php.

Now, although the site at http://domain.com/staging/ seems to be working, I'm getting the following errors at the top of my page:

Warning (2): mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 117]

Warning (2): mysql_select_db(): supplied argument is not a valid MySQL-Link resource [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 122]

Warning (2): mysql_get_server_info(): supplied argument is not a valid MySQL-Link resource [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 130]

Warning (2): mysql_real_escape_string() expects parameter 2 to be resource, boolean given [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 247]

Warning (2): mysql_query(): supplied argument is not a valid MySQL-Link resource [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 152]

Warning (2): mysql_errno(): supplied argument is not a valid MySQL-Link resource [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 329]

Warning (2): session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /users/ia/www.cantifix.co.uk/cake/basics.php:111) [CORE/cake/libs/session.php, line 535]

Warning (2): Cannot modify header information - headers already sent by (output started at /users/ia/www.cantifix.co.uk/cake/basics.php:111) [CORE/cake/libs/session.php, line 536]

What's going on? My database connection settings seem to be correct as like aforementioned, the site works as it should (except for these error messages).

If any one has any tips or pointers for multiple apps using a single cake library, I'd be most grateful.

3

3 Answers

0
votes

i used dozens of those "app" folders in the same dir. it all works perfectly without any configuration overhead

why are you changing your CAKE_CORE_INCLUDE_PATH? leave it as it was. also leave ROOT as dynamic default:

define('ROOT', dirname(dirname(dirname(__FILE__))));

cake will take care of everything itself.

also note: you should set your VirtualHost down to webroot. example setup: http://www.dereuromark.de/2011/05/29/working-with-domains-locally/

then there should be no problem.

0
votes

I too have many projects in Cakephp and all I needed to do was to clone app/ and rename it. I did not need to change cake_core_include_path. All I needed was to setup another vhost to point to the new directory's webroot.

Maybe you copied a lock file?

Warning (2): mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through
socket '/var/run/mysqld/mysqld.sock' (2) [CORE/cake/libs/model/datasources/dbo/dbo_mysql.php, line 117]

This seem to be the error that is triggering all the rest of the errors. The rest of the mysql errors were expecting resource but got a false boolean. The header errors are due to the error outputs most likely

0
votes

Fixed! Turns out it was a problem with my database.php configuration file. I copied the values from my $staging array to the $default array and cleared the tmp folder, and balance was restored in the universe.