"Invalid argument" Problem!
7 posts
• Page 1 of 1
"Invalid argument" Problem!
Hi,
i worked with lots of shop-systems, but i think your one is really easy to used and also good designed!! Great job, but i have a problem with the "Invalid argument" - Request.
I get this messages on the Front and at the Backend at every Action:
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/user/main/shop/system/library/cache.php:18) in /www/htdocs/user/main/shop/system/library/response.php on line 65
My server use PHP 5.2.6 ....
So, what´s wrong? I set the required folders and cache.php to 777, otherwise it will be crashed, but nothing changed! ;(
Can anyone help me?
i worked with lots of shop-systems, but i think your one is really easy to used and also good designed!! Great job, but i have a problem with the "Invalid argument" - Request.
I get this messages on the Front and at the Backend at every Action:
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 18
Warning: Invalid argument supplied for foreach() in /www/htdocs/user/main/shop/system/library/cache.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/user/main/shop/system/library/cache.php:18) in /www/htdocs/user/main/shop/system/library/response.php on line 65
My server use PHP 5.2.6 ....
So, what´s wrong? I set the required folders and cache.php to 777, otherwise it will be crashed, but nothing changed! ;(
Can anyone help me?
- Spike
- Posts: 11
- Joined: Fri Feb 13, 2009 8:47 am
Re: "Invalid argument" Problem!
Hey spike, i had the same problem.
You can put an .htaccess file in your web server's root directory and enter there:
php_value display_errors 0
save it.
This should do the trick.
Greetz daelsta
You can put an .htaccess file in your web server's root directory and enter there:
php_value display_errors 0
save it.
This should do the trick.
Greetz daelsta
- daelsta
- Posts: 23
- Joined: Thu Oct 11, 2007 4:00 am
Re: "Invalid argument" Problem!
Hey daelsta,
great - that´s it!! Thx!!
Greetz, Spike
great - that´s it!! Thx!!
Greetz, Spike
- Spike
- Posts: 11
- Joined: Fri Feb 13, 2009 8:47 am
Re: "Invalid argument" Problem!
php_value display_errors 0 is a quick fix but turns off error reporing.
the problem is php's glob function. it won't read files with in the cache directory.
I'm going to fix this properly using fopen.
the problem is php's glob function. it won't read files with in the cache directory.
I'm going to fix this properly using fopen.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
Project Owner & Developer.
OpenCart commercial support now available!
-

Daniel - Administrator
- Posts: 5173
- Joined: Fri Nov 03, 2006 10:57 am
Re: "Invalid argument" Problem!
fixing the error would be the best solution 
ps: daniel, just have to tell you that your new opencart is absolutely awsome. thanks for your work!

ps: daniel, just have to tell you that your new opencart is absolutely awsome. thanks for your work!
- daelsta
- Posts: 23
- Joined: Thu Oct 11, 2007 4:00 am
Re: "Invalid argument" Problem!
Replace your cache file with this:
The problem is that the glob function returns false and not array when nothing is found. Also I would check that you have set the right permission on the cache directory.
- Code: Select all
<?php
final class Cache {
private $expire = 3600;
public function __construct() {
$files = glob(DIR_CACHE . 'cache.*');
if ($files) {
foreach ($files as $file) {
$time = end(explode('.', basename($file)));
if ($time < time()) {
unlink($file);
}
}
}
}
public function get($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
$handle = fopen($file, 'r');
$cache = fread($handle, filesize($file));
fclose($handle);
return unserialize($cache);
}
}
}
public function set($key, $value) {
$this->delete($key);
$file = DIR_CACHE . 'cache.' . $key . '.' . (time() + $this->expire);
$handle = fopen($file, 'w');
fwrite($handle, serialize($value));
fclose($handle);
}
public function delete($key) {
$files = glob(DIR_CACHE . 'cache.' . $key . '.*');
if ($files) {
foreach ($files as $file) {
unlink($file);
}
}
}
}
?>
The problem is that the glob function returns false and not array when nothing is found. Also I would check that you have set the right permission on the cache directory.
Last edited by Daniel on Fri Feb 13, 2009 5:37 pm, edited 1 time in total.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
Project Owner & Developer.
OpenCart commercial support now available!
-

Daniel - Administrator
- Posts: 5173
- Joined: Fri Nov 03, 2006 10:57 am
Re: "Invalid argument" Problem!
seems like this fixed the error (folder permissions already were 777)
thanks
thanks
- daelsta
- Posts: 23
- Joined: Thu Oct 11, 2007 4:00 am
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests













