I need your help

In a script, I build an array out of the values that are stored in the database. I do this with the following function:
Code: Select all
function products2array ($db)
{
$array = array();
// Basic product information
$query = "SELECT * FROM phpwcms_products ORDER BY prod_id";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$array[$row["product_name"]]["category"] = $row["category"];
$array[$row["product_name"]]["system_req"] = $row["system_req"];
$array[$row["product_name"]]["contact_name"] = $row["contact_name"];
$array[$row["product_name"]]["prices"] = array();
// Add product price information to array
$query2 = "SELECT * FROM ".DB_PREPEND."phpwcms_products_prices WHERE prod_id = ".$row["prod_id"]." ORDER BY display_pos";
$result2 = mysql_query($query2);
while ($row2 = mysql_fetch_assoc($result2))
{
$array[$row["product_name"]]["prices"][$row2["display_pos"]]["description"] = $row2["description"];
$array[$row["product_name"]]["prices"][$row2["display_pos"]]["value"] = $row2["value"];
}
}
return $array;
}
Code: Select all
[bit-ACL-Explorer] => Array
(
[category] => Notes
[system_req] => Lotus Notes 4.5 oder höher
[contact_name] => Roland Hein
[prices] => Array
(
[1] => Array
(
[description] => Server: 1 Lizenz
[value] => 460
)
[2] => Array
(
[description] => Server: 2 Lizenzen
[value] => 322
)
)
)
Code: Select all
function products_get_category ($product_name, $array)
{
return $array[$product_name]["category"];
}
Unfortunately, it could also be possible that I've got a product name with an apostroph ' in it. This would produce an array like the following:
Code: Select all
[bit-Mail'n'Time] => Array
(
[category] => Notes
[system_req] => Lotus Notes Clientversionen 4.5 oder höher, Server Domino R5 oder höher
[contact_name] => Thomas Brausch
[prices] => Array
(
[1] => Array
(
[description] => bis 10 Gruppenlizenzen
[value] => 3045
)
[2] => Array
(
[description] => bis 25 Gruppenlizenzen
[value] => 3870
)
)
)

Has someone of you an idea how to solve this? To be honest, I am a bit too tired at the moment to get a clear thought...
Thanks in advance
- Jérôme