djohns57 Posted January 5, 2009 Share Posted January 5, 2009 I am getting the following error: Fatal error: Cannot redeclare stripslashes_array() (previously declared in /home/content/d/j/o/djohns57/html/specialtysales/oscommerce/catalog/parse/index.php:31) in /home/content/d/j/o/djohns57/html/specialtysales/oscommerce/catalog/parse/index.php when I try to upload my product file in .csv format into oscommerce. I am using the following script: <?php if(isset($_POST['submit'])){ include('connect/db.inc.php'); ini_set('allow_url_fopen', 'on'); $category_id = $_POST['category']; require("MagicParser.php"); ########################## # DEFINE THE NEW FILE NAME ########################## $file = "Sports_memorabilia_1-05-08.txt"; $category = "Sports Collectibles"; function myRecordHandler($record) { // This is where you write your code to process each record, such as loading a database // You can display the record contents using PHP's internal print_r() function: foreach($record as $key=>$val){ if (get_magic_quotes_gpc()) { function stripslashes_array($array) { return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array); } $_COOKIE = stripslashes_array($_COOKIE); $_FILES = stripslashes_array($_FILES); $_GET = stripslashes_array($_GET); $_POST = stripslashes_array($_POST); $_REQUEST = stripslashes_array($_REQUEST); } #echo $key . ' - ' . $val . '<br>'; if($key === "TITLE"){ $_POST['title'] = $val; } if($key === "DESCRIPTION"){ $_POST['description'] = $val; } if($key === "QTY_AVAIL"){ $_POST['qty_avail'] = $val; } if($key === "IMAGE_URL"){ $_REQUEST['image_url'] = $val; } if($key === "PRICE"){ $_POST['p_price'] = $val . '00'; } if($key === "WEIGHT"){ $_POST['weight'] = $val; } if($key === "BRAND"){ $_POST['brand'] = $val; } } $today = date("Y-m-d G:i:s"); $currentFile = $_REQUEST['image_url']; $parts = Explode('/', $currentFile); $currentFile = $parts[count($parts) - 1]; ini_set('allow_url_fopen', 'on'); $file = fopen("{$_REQUEST['image_url']}" , "rb"); copy ($_REQUEST['image_url'] , "/home/content/d/j/o/djohns57/html//specialtysales/oscommerce/catalog/images/$currentFile"); $sql_PI = "INSERT INTO products(products_quantity, products_model, products_image, products_price, products_date_added, products_last_modified, products_weight, products_status, products_tax_class_id) VALUES('{$_POST['qty_avail']}', '{$_POST['brand']}', '$currentFile', '{$_POST['p_price']}', '{$today}', '{$today}', '{$_POST['weight']}', '1', '1')"; $res_PI = mysql_query($sql_PI) or die(mysql_error()); $sql_RI = "SELECT MAX(products_id) AS id FROM products"; $res_RI = mysql_query($sql_RI) or die(mysql_error()); $row_RI = mysql_fetch_assoc($res_RI); $_products_id = $row_RI['id']; $sql_PC = "INSERT INTO products_to_categories (products_id, categories_id) VALUES('{$_products_id}', '{$_POST['category']}')"; $res_PC = mysql_query($sql_PC) or die(mysql_error()); $sql_PD = "INSERT INTO products_description (language_id, products_name, products_description, products_viewed) VALUES ('1', '{$_POST['title']}', '{$_POST['description']}', '0')"; $res_PD = mysql_query($sql_PD) or die(mysql_error()); } MagicParser_parse($file,"myRecordHandler","csv|44|1|0"); } else{ include('connect/db.inc.php'); $sql = "SELECT * FROM categories_description"; $res = mysql_query($sql) or die(mysql_error()); echo '<form name="cat_select" method="post" action=' . $_SERVER['PHP_SELF'] . '>'; echo '<select name="category">'; while($row = mysql_fetch_assoc($res)){ $cat = $row['categories_name']; $cat_id = $row['categories_id']; if($cat != ''){ echo '<option value=' . $cat_id . '>' . $cat . '</option>'; } } echo '</select>'; echo '<br>'; echo '<input type="submit" name="submit" value="submit">'; echo '<br>'; echo '</form>'; } ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.