Hi,
I've built a language system for my CMS & when i try to set more than one case it says argument #2 not array, when i know it is.
Language Class:
English.php file:
While doing a while() query i'm getting argument #2 not array.
Example:
It's just an example, the point i'm trying to get across is argument #2 is array.
If i do $lang->Add("housekeeing.menu." . $lang_cat); once it's fine, but when add more cats i get the arguments #2 not array.
I don't understand the problem.
The actual functions im using this in:
It sets the first part of the menu locale, but then i get argument #2 not array when it does more than 1 adding.
Thanks.
I've built a language system for my CMS & when i try to set more than one case it says argument #2 not array, when i know it is.
Language Class:
PHP:
class Language
{
public $loc = array();
public function Add($keys)
{
if(is_array($keys))
{
foreach($keys as $key)
{
require_once LANG_DIR . "English.php";
$this->loc = array_merge($this->loc, $loc);
}
}
else
{
$key = $keys;
require_once LANG_DIR . "English.php";
$this->loc = array_merge($this->loc, $loc);
}
}
public function Dump()
{
unset($this->loc);
}
}
English.php file:
PHP:
switch($key)
{
case "housekeeping.menu.staff":
$loc['menu.staff.title'] = "Staff";
$loc['menu.staff.home'] = "Home";
$loc['menu.staff.rules'] = "Rules";
$loc['menu.staff.logout'] = "Logout";
break;
case "housekeeping.menu.news":
$loc['menu.news.title'] = "News";
break;
}
While doing a while() query i'm getting argument #2 not array.
Example:
PHP:
while($stmt->fetch())
{
$lang->Add("housekeeing.menu." . $lang_cat);
}
It's just an example, the point i'm trying to get across is argument #2 is array.
If i do $lang->Add("housekeeing.menu." . $lang_cat); once it's fine, but when add more cats i get the arguments #2 not array.
I don't understand the problem.
The actual functions im using this in:
PHP:
public function BuildMenu($url)
{
$stmt = $this->db->stmt_init();
$return = "";
if($stmt->prepare("SELECT id, language_set, language_get FROM pegg_cms_hk_menu WHERE parent_id = 0 AND minrank <= ? ORDER BY order_id + 0"))
{
$stmt->bind_param("i", $this->server->site->GetDataByUsername($_SESSION['PEGG']['HK']['USERNAME'], "rank"));
$stmt->bind_result($id, $lang_set, $lang_get);
$stmt->execute();
$stmt->store_result();
while($stmt->fetch())
{
$this->lang->Add("housekeeping.menu." . $lang_set);
$return .= "<div class=\"box-container\">";
$return .= "<div class=\"head-container\">" . $this->lang->loc['menu.' . $lang_set . "." . $lang_get] . "</div>";
$return .= "<div class=\"menuitems-container\">";
$return .= $this->BuildSubMenu($id, $url);
$return .= "</div>";
$return .= "</div>";
}
$stmt->close();
}
else
{
LogError($this->db->error, "mysqli");
TriggerError("MySQLi Error", $this->db->error);
}
return $return;
}
public function BuildSubMenu($parent, $url)
{
$stmt = $this->db->stmt_init();
$return = "";
if($stmt->prepare("SELECT language_set, language_get, url, resource FROM pegg_cms_hk_menu WHERE parent_id = ? AND minrank <= ? ORDER BY order_id + 0"))
{
$stmt->bind_param("ii", $parent, $this->server->site->GetDataByUsername($_SESSION['PEGG']['HK']['USERNAME'], "rank"));
$stmt->bind_result($lang_set, $lang_get, $url2, $resource);
$stmt->execute();
$i = "a";
while($stmt->fetch())
{
if($url == $url2)
{
$return .= "<div class=\"" . $i . " selected-link\">";
$return .= $this->lang->loc['menu.' . $lang_set . "." . $lang_get];
$return .= "</div>";
}
else
{
$return .= "<a href=\"" . $this->config->settings->housekeeping->path . "/index.php?url=" . $url2 . "\" class=\"" . $i . "\">";
$return .= $this->lang->loc['menu.' . $lang_set . "." . $lang_get];
$return .= "</a>";
}
$i++;
if($i == "c")
{
$i = "a";
}
}
$stmt->close();
}
else
{
LogError($this->db->error, "mysqli");
TriggerError("MySQLi Error", $this->db->error);
}
return $return;
}
It sets the first part of the menu locale, but then i get argument #2 not array when it does more than 1 adding.
Thanks.

