Archive for June 22nd, 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 ..
Add comment June 22, 2006
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?
18 comments June 22, 2006
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.
Add comment June 22, 2006