Angad
Angad

Reputation: 2823

CakePHP not working, showing PHP Code inline PHP

Edit: I know what is causing the problem now, but still no solution. Basically unless the tmp directory is 777 Cake is unable to write to it so it fails. And if tmp is 777 then because of maybe some weird security setting PHP doesn't work. Any ideas if this is a possibility and how I can fix it?

Edit 2: Is it possible that because of character encoding the tmp is not 777 its showing ? garbage characters.

I just migrated my CakePHP app to Amazon AWS (Using a BitNami LAMPstack). I was getting PHP errors saying Could Not Connect to DB (which means PHP is executing).

When I fixed the DB settings it is now printing inline PHP. For example:

<title><?php echo $title_for_layout; ?></title>

is showing in the HTML and the document title is hence a snippet of PHP code!

Please help I'm at a loss. Things I've tried doing:

Here are my .htaccess files just in case:

htdocs/.htaccess

<IfModule mod_rewrite.c>
       RewriteEngine on
       RewriteRule    ^$ app/webroot/    [L]
       RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Options All -Indexes

htdocs/app/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

htdocs/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>

Upvotes: 1

Views: 736

Answers (1)

Angad
Angad

Reputation: 2823

Well all I can say is thank god I paid attention in class last semester when they explained character encoding.

So I opened up all the .ctp files that weren't being exec'd as PHP in vim. I said :set encoding=utf-8 and :set fileencoding=utf-8 and then :x (keeping it newb-friendly just in case somebody wants a quick fix) :)

And its working like it should now. :)

Upvotes: 1

Related Questions