Archive for June, 2006

multiple select error

Problem: when i try to use a multiple select tag, I always encounter this error after i submit the form
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /path/to/cake/lib/cake/basics.php on line 436

Obviously, its asking for string instead of array (which is what the mulitple select tag will pass) . So, i just change it to accept array..

function h($text) {
if (is_array($text)) {
foreach ($text as $val) {
$new[] = htmlspecialchars($val);
}
} else {
$new = htmlspecialchars($text);
}
return $new;
//return htmlspecialchars($text); // this is the old code

}

Another problem: it cannot automatically select the selected items.

Solution: I’d post this some other day 😀 hehe.. need to get back to work ..

Advertisements

June 22, 2006 at 3:02 pm Leave a comment

new installation of cake: open_basedir restriction error

Problem: new installation of cake to a subfolder only. I get this error

Warning: file_exists(): open_basedir restriction in effect. File(/usr/share/pear/cake/libs/controller/components/session.php) is not within the allowed path(s): …path… in /path/to/core/folder/cake/basics.php on line 854

Error occurs within the function fileExistsInPath in basics.php

Solution: change the fileExistsInPath function to:

function fileExistsInPath($file) {
$paths = explode(PATH_SEPARATOR, ini_get(‘include_path’));
// removing /usr/share/pear from the list of includes_path
array_shift($paths); //added
array_shift($paths); //added
// the rest goes here
}
Explanantion: In my conversation with one cake bakers, some server cannot find cake libs which we had included already bec it only sees the /usr/share/pear folder. So he (simreg in particular) removed the first 2paths in the include path to give way to our own cake lib paths.

This is not really the best solution, but this works for me now. I still have no idea why that happens. For now, I’l stick with that.

Any idea?

June 22, 2006 at 2:55 pm 19 comments

saving in a loop

Just found this on google groups

Question: How to save (Model->save()) in a loop without overwriting the first one:

Workaround:

After calling $this->Model->save( ), call $this->Model->create( ).
This will re-initialize the model for writing new data.

June 22, 2006 at 2:16 pm Leave a comment

always use html->link

Always use $html->link when creating links. This html helper appends your base path to the beginning. This is helpful when your settings is in a subfolder.

Example, your webroot is in ‘https://cakensoda.wordpress.com/cake’. Without using the html link helper, your links will only be ‘/controller/action’ instead of ‘/cake/controller/action’

I learned this in a not-so-friendly way bec i used the a link tag before to form my links. But when my webroot was moved to a subfolder, every link didnt work!

Also, if you cannot use $html->link due to some special reasons, I use the $html->base to append my base path.

June 20, 2006 at 1:27 pm Leave a comment

I love Cake!

Finding about cakePhp was heaven! LOL Basically, it makes my life as a programmer easier and more productive. This is still a very young framework tho, but its promising already. IPAGPATULOY NYO LANG MGA BAKERS! <– love them

There is only one precaution tho, CAKE is very addictive! Don’t worry, there is no sugar 😉

June 6, 2006 at 4:50 pm Leave a comment


Recent Posts

June 2006
M T W T F S S
    Jul »
 1234
567891011
12131415161718
19202122232425
2627282930