Jump to content

amwd07

Members
  • Posts

    161
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

amwd07's Achievements

Member

Member (2/5)

0

Reputation

  1. ok I now feel alone with this issue although defferently moving forward, have now found the right solution to my problem but need assistance implementing. The problem is I can not loop through the product ID's, this is because it would seem I can only use 1 foreach loop for my resultRtn array, I need to be able to loop through the product ID's so I can set these as keys for example array(pID => attID) <?php // $selAtt = FilterSearch::getProductsAttributesID($expr); // example output of this array // [0] => Array ( [id_product] => 31 [id_attribute] => 39 ) // [1] => Array ( [id_product] => 31 [id_attribute] => 48 ) // [2] => Array ( [id_product] => 31 [id_attribute] => 63 ) // [3] => Array ( [id_product] => 31 [id_attribute] => 96 ) // $attArray = array(); // foreach($newExp as $attID) // foreach($selection as $pID) // Method 1 $attArray = array(); foreach($newExp as $attID) { $resultRtn = array( id_product => 'return ( $att["id_product"] == "'.$selection.'" );', // Notice: Use of undefined constant id_product - assumed 'id_product' id_attribute => 'return ( $att["id_attribute"] == "'.$attID.'" );', // This one works fine ); $attUsr = create_function('$att', $resultRtn); $filtered_results = array_filter($selAtt, $attUsr); $attArray[] = $attID; $count = count($filtered_results); echo "Attribute Found ".$attID.": (".$count.")<br \>"; } print_r($attArray); ?>
  2. ok I now feel alone with this issue although defferently moving forward, have now found the right solution to my problem but need assistance implementing. The problem is I can not loop through the product ID's, this is because it would seem I can only use 1 foreach loop for my resultRtn array, I need to be able to loop through the product ID's so I can set these as keys for example array(pID => attID) // $attArray = array(); // foreach($newExp as $attID) // foreach($selection as $pID) // Method 1 $attArray = array(); foreach($newExp as $attID) { $resultRtn = array( id_product => 'return ( $att["id_product"] == "'.$selection.'" );', id_attribute => 'return ( $att["id_attribute"] == "'.$attID.'" );', ); $attUsr = create_function('$att', $resultRtn); $filtered_results = array_filter($selAtt, $attUsr); $attArray[] = $attID; $count = count($filtered_results); echo "Attribute Found ".$attID.": (".$count.")<br \>"; } print_r($attArray);
  3. I believe I may be able to do something like this before the query but not sure what I can put in the filterGroups callback function? $selection = array_filter($selection,$this->filterGroups);
  4. I am trying to filter the results query before retuning the function <?php $queryResults = ' SELECT DISTINCT SQL_CALC_FOUND_ROWS p.*, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`, t.`rate`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = cp.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON p.`id_product` = pa.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.intval($id_lang).') LEFT OUTER JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.intval($id_lang).') LEFT JOIN `'._DB_PREFIX_.'tax` t ON (p.`id_tax` = t.`id_tax`) LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) WHERE cp.`id_category` = '.intval($currentCategory).' AND p.`active` = 1 AND '.(($range == false && $selection && sizeof($selection)) ? ' p.`id_product` IN ('.implode(',', array_map('intval', $selection)).')' : $whereBy).' AND a.`id_attribute` IN (49,97,110) // this does not filter '.($orderBy ? 'ORDER BY '.$orderBy : '').($orderWay ? ' '.$orderWay : '').' LIMIT '.intval(($pageNumber - 1) * $pageSize).','.intval($pageSize); $result = Db::getInstance()->ExecuteS($queryResults) or die(mysql_error()); $total = Db::getInstance()->getValue('SELECT FOUND_ROWS()'); $result = Db::getInstance()->ExecuteS($queryResults) or die(mysql_error()); ?> this would return 3 results which is correct but when I try to add a second array map into the above query this still returns 3 results, there should only be one result, so I have come to the conclusion this can not be done within SQL so I would like to filter my result from the DB query $result = /// $result['id_attribute'] filter array('49','97','110','95'); = 1 product then return $result; (Previously used SQL)
  5. Hello for 2 days I have tried to resolve my permissions issue 1st tried to install Fast CGI & gave up on this today & decided to go with suPHP I run ubuntu 8.10 have used this command to install suPHP apt-get install libapache2-mod-suphp then this command to disable mod php a2dismod php5 the problem is I am getting this error when restarting the server Syntax error on line 3 of /etc/apache2/mods-enabled/suphp.conf: suPHP_AddHandler not allowed here Anyone any suggestions how to fix this please :'(
  6. Hello struggling again after resolving my 1st issue all 100 categories are entered into the DB the problem now which is stopping going further on this project is the correct category values in the DB are incorrect all categories show the same value in this case 486 which is the last category Id printed from the array. each subcategory should have the correct parent category (id_xpress_cat) but doesn't for some reason??? if(isset($_GET['viewsubcat'])){ foreach($this->_data['categories'] as $cat_name => $cat_count) { echo $cat_name."<br>"; } foreach($this->_data['product'] as $key => $data) { $xpress_cat = $data['item_category']; // echo $data['item_category']."<br />"; } if($addcat || $updatecat) { $active = '1'; if($row_xcat = dbSelect("SELECT * FROM ".WEBZSQL_DB_PREFIX."xpress_subcategory WHERE subcat_name = '".$cat_name."'",1)) { $id_subcat = $row_cat->id_subcat; if($row_xcat) { dbUpdate(WEBZSQL_DB_PREFIX."xpress_subcategory",array("id_xpress_cat" => $data['item_category']),' id_subcat = "'.$id_subcat.'" '); } }
  7. right the category name is working but without id_xpress_cat with that in it produces 300 categories foreach($this->_data['categories'] as $cat_name => $cat_count) { // subcategory does not exists! $fields_cat = array("id_xpress_cat" => $data['item_category'], // added to insert xpress category ID! "subcat_name" => $cat_name, // "link_rewrite" => urlfriendly($data['categories']), "active" => '1', "date_add" => NOW, "date_upd" => NOW); $id_subcat = dbInsert(WEBZSQL_DB_PREFIX."xpress_subcategory",$fields_cat); $addsubcat = true; }
  8. why would this happen if I am looping? example DB ID Parent SubCat Active 31 493 Accessories 1 32 493 LCD 1 33 493 LCD 1 34 493 LCD 1 but there are about 10 categories so why does this duplicate after the 1st one?
  9. right now I have got further foreach($this->_data['categories'] as $cat_name => $cat_count) { // subcategory does not exists! $fields_cat = array("id_subcat" => $id_subcat, "id_xpress_cat" => $data['item_category'], // added to insert xpress category ID! "subcat_name" => $cat_name, // "link_rewrite" => urlfriendly($data['categories']), "active" => '1', "date_add" => NOW, "date_upd" => NOW); $id_subcat = dbInsert(WEBZSQL_DB_PREFIX."xpress_subcategory",$fields_cat); $addsubcat = true; } this enters Accessories into the DB and enters LCD 29 times for some reason giving these errors SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '31' for key 1] 1: AM-ST100H-BRACKET updated. SQL/DB Error -- [Duplicate entry '31' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '32' for key 1] 2: BL-AV24105QP updated. SQL/DB Error -- [Duplicate entry '32' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1] SQL/DB Error -- [Duplicate entry '33' for key 1]
  10. Hello I have been struggling now for the past 4hrs to print_r element so I can enter the elements into the DB. I am trying to fetch all the sub categories for a particualar category so all [categories] should be entered into the DB currently Array shows in the DB ??? Object ( [_data] => Array ( [recordcount] => 31 [outofstock] => 17 [instock] => 14 [nopages] => 1 [categories] => Array ( [Accessories] => 7 [LCD] => 1 [LCD TV] => 1 [Media and Play] => 5 [Media Center] => 4 [Photo Frame] => 1 [Remote Control] => 3 [switch] => 3 [TV Tuner] => 5 [Wireless] => 1 ) I have tried various methods // 1ST attempt $subcat = current($this->_data['categories']); $first_array = array("categories" => $subcat); echo $first_array['categories']; // second attempt print_r($this->_data['categories']); // third attempt echo $this->_data['categories'][] = array tried other things but no use Please anyone any idea's?
  11. any one any idea's how to get this issue resolved. I have now changed the code but still not working ??? <?php // Get Main Content from DB function ValidGet($var,$type,$default=false) { $var_value == $_GET[$var]; switch($type){ case 'INT': $var_value = preg_replace("/[^0-9]/","",$var_value); break; } } if($id = ValidGet('content_id','INT')) { $content = $db->get_row("SELECT `section_heading`,`short_desc`,`main_desc` FROM `content` WHERE `content_id` = '".$id."'"); } $db->debug(); if (empty($id) || !$content) { $error = 'No hackers!'; echo $error; } else { echo "<div id='main'>"; } ?>
  12. All I need to do here is only allow validate ID in the DB to make this more secure <?php // Get Main Content from DB $id = $_GET['content_id']; $content = $db->get_row("SELECT `section_heading`,`short_desc`,`main_desc` FROM `content` WHERE `content_id` = '".intval($id)."'"); $content_id = $content->content_id; /* function isValidID($id) { $id = intval($id); return is_numeric($id) AND $id > 0 AND $id < 1000; } */ if (empty($content_id)) { $error = 'No hackers!'; echo $error; } else { echo "<div id='main'>"; ?>
  13. sorry might be mis understanding this one, also realise wrong fields were queried $id = $_GET['content_id']; $content = $db->get_row("SELECT `section_heading`,`short_desc`,`main_desc` FROM `content` WHERE `content_id` = '".intval($id)."'"); function isValidID($id) { $id = intval($id); return is_numeric($id) AND $id > 0 AND $id < 4294967296; } if (!empty($id) or !isValidID($id)) { $error = 'No hackers!'; echo $error; else { echo "<div id='main'>";
  14. Hi hopefully someone can help or advice me here please. I am using the EZSQL MYSQL class & would like to query the ID based on the URL Not sure if the below is secure? $id = $_GET['content_id']; $content = $db->get_row("SELECT `heading`,`desc`,`desc` FROM `content` WHERE `content_id` = '".intval($id)."'"); also I would like to try to get this function to work which I think would make this more secure again not sure if this is the right solution. open for suggestions on this one function isValidID($id) { $id = intval($id); return is_numeric($id) AND $id > 0 AND $id < 4294967296; } if (!isset($id) OR isValidID($id)) $errors = 'No hackers!'; else { content here .... }
  15. Sorry guys My code was correct is was the file permissions which was the problem
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.