Jump to content

motorcity

Members
  • Posts

    31
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

motorcity's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Finally figured this out by comparing the 5.2.9 php.ini to the current php 5.3.29 php.ini The default max_input_vars = 1000 was the culprit. Thanks for all the help, I really do appreciate it. ~Motorcity Not sure how to mark this solved, but it is.
  2. Really appreciate you taking a look here. I thought that last part about tep_db_ or mysql_ query was worth a quick going over and found that using $query = tep_db_query() in the place of mysql_query didn't bother any functioning files, and it didn't change anything that doesn't work. There has to be some sort of corruption in the data that just blows my mind because it spans multiple product groups and never reared its head until this switch in php & mysql.
  3. Thanks. To be more precise on form submission $_POST['reset'] or $_POST['save'] if the script is working you get a page refresh and a new total reflecting any changes, and a revised sort order. If not working, it still refreshes the page but it changes nothing. There are a number of php notices for undefined variables and indexes, but those were there before php5.3 and are common between those versions that work and those that don't. That the posted code is exactly the same with the hard coded vendors2_id being the only difference is really the point. And it sounds like your judgement is the problem isn't in the code. With a possible check of the php configuration probably due.
  4. I should probably explain works or doesn't work. Either way the file displays a sortable list by column headings with suggested products to order based on quantity in stock. The user can override the "approved" by clicking the checkbox off. What doesn't work is RESET or SAVE the order. Thanks for looking and any suggestions you may have.
  5. I've been up down and around in circles with this script. I know it's poor coding, but it has served its purpose. Incredibly it has worked for years and what I'm sharing here is the same code used for multiple vendors and manufacturers. The part that completely throws me is that it still works after the change from PHP 5.2.9 to PHP 5.3 for half of the vendors and doesn't work on the other half. I keep going back to the database (also updated from mysql 5.0.96 to mysql 5.5.42) a single column "vendors2_id" in the products table makes the difference of whether this code works or fails for the most part, and I've been all through the database convinced that somehow there is some sort of corruption in a table or a single product, but I believe that just isn't the case. Now I'm asking two things; Is php5.3 that much more exacting than 5.2 that something here works but only half of the time? (The ONLY difference is the number used I.E. vendors2_id = 16 works, vendors2_id = 4 does not work.) Or is it absolutely a problem in my database? <?php require('includes/application_top.php'); define('MAX_RESULTS', '1000'); //set_time_limit(300); function get_products_reorder_to($products_quantity, $reorder_quantity, $shelf_pack,$products_reorder_to){ $new_reorder_to = 0; if($products_quantity < $reorder_quantity && $shelf_pack > 0){ for($new_reorder_to = $shelf_pack;($new_reorder_to + $products_quantity) < $reorder_quantity;){ $new_reorder_to += $shelf_pack; } } if($products_reorder_to > 0) $new_reorder_to = $products_reorder_to; return $new_reorder_to; } //end function if($_POST['reset']){ $reset_query = tep_db_query("select products_id, products_quantity, shelf_pack, reorder_quantity from " . TABLE_PRODUCTS . " where vendors2_id = 16 and products_quantity < reorder_quantity"); while ($reset_select = tep_db_fetch_array($reset_query)) { $jd = get_products_reorder_to($reset_select['products_quantity'], $reset_select['reorder_quantity'], $reset_select['shelf_pack'], 0); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET products_reorder_to = '" . $jd . "' WHERE vendors2_id = 16 and products_id = '" . $reset_select['products_id'] . "'"); } mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = '1' WHERE vendors2_id = 16 and products_quantity < reorder_quantity "); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = '0', products_reorder_to = '0' WHERE vendors2_id = 16 and products_quantity >= reorder_quantity "); }//post reset if($_POST['save'] || $_POST['autosave'] == '1'){ if($_POST['add2order'] != '') $idchecked = join(",", $_POST['add2order']); if($_POST['add2orderlist'] != '') $idlist = join(",", $_POST['add2orderlist']); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = 1 WHERE vendors2_id = 16 and products_id in (" . $idchecked . ")"); mysql_query("UPDATE " . TABLE_PRODUCTS . " SET approved = 0 WHERE vendors2_id = 16 and products_id in (" . $idlist . ") and products_id NOT in (" . $idchecked . ")"); }//post save ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <link rel="stylesheet" type="text/css" href="includes/stylesheet.css"> <script language="javascript" src="includes/general.js"></script> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <form name="order_quantity" method="post"> <table border="0" width="100%" cellspacing="2" cellpadding="2"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); $sorted = $HTTP_GET_VARS['sorted']; $orderby = $HTTP_GET_VARS['orderby']; if ($sorted !== "ASC" and $sorted !== "DESC") $sorted = "ASC"; ?> <!-- left_navigation_eof //--> </table></td> <!-- body_text //--> <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <?php $products_query_raw = "select p.products_id, p.products_model, p.products_quantity, pd.products_name, p.products_sku, p.reorder_quantity, p.products_reorder_to, p.shelf_pack, p.vendors_product_price, pr.manufacturers_name, p2c.categories_id from " . TABLE_PRODUCTS . " p inner join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id inner join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left outer join " . TABLE_MANUFACTURERS . " pr on p.manufacturers_id = pr.manufacturers_id where p.vendors2_id = 16 and pd.language_id = '" . $languages_id. "' and p.approved=1 group by pd.products_id "; $products_query = tep_db_query($products_query_raw); while ($products = tep_db_fetch_array($products_query)) { $new_reorder_to = get_products_reorder_to($products['products_quantity'], $products['reorder_quantity'], $products['shelf_pack'], $products['products_reorder_to']); $subtotal = $new_reorder_to * $products['vendors_product_price']; $total += $subtotal; } ?> <td class="pageHeading" align="left">ABC Company</td> <td class="main" align="left">Grand Total = $<?php echo $total;?></td> <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td> </tr> </table></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_NUMBER; ?></td> <td class="dataTableHeadingContent"><?php if (!isset($orderby) or ($orderby == "sku" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=sku&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_PROD_ID . '</a>'; ?> </td> <td class="dataTableHeadingContent"><?php if (!isset($orderby) or ($orderby == "model" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=model&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' . TABLE_HEADING_MODEL . '</a>'; ?></td> <td class="dataTableHeadingContent"><?php if (!isset($orderby) or ($orderby == "name" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=name&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' . TABLE_HEADING_PRODUCTS . '</a>'; ?></td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "cost" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=cost&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_PRICE_LEFT . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "shelf" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=shelf&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_SHELF . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right" bgcolor="FFCCCC"><?php if (!isset($orderby) or ($orderby == "stock" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=stock&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_QTY_LEFT . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right" bgcolor="CCFF99"><?php if (!isset($orderby) or ($orderby == "reorder" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=reorder&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_REORDER . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "reorder2" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=reorder2&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">' .TABLE_HEADING_REORDER2 . '</a>'; ?> </td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "total" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=total&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">'. TABLE_HEADING_LINE_T. '</a>'; ?></td> <td class="dataTableHeadingContent" align="right"><?php if (!isset($orderby) or ($orderby == "approved" and $sorted == "ASC")) $to_sort = "DESC"; else $to_sort = "ASC"; echo '<a href="' . tep_href_link(FILENAME_STATS_INVENTORY16, 'orderby=approved&sorted='. $to_sort.($_GET['page']>0?'&page='.$_GET['page']:'')) . '" class="headerLink">'.TABLE_HEADING_CHECK_T. '</a>'; ?></td> </tr> <?php if ($HTTP_GET_VARS['page'] > 1) $rows = $HTTP_GET_VARS['page'] * 20 - 20; if ($orderby == "name") {$db_orderby = "pd.products_name";} elseif ($orderby == "stock") {$db_orderby = "p.products_quantity";} elseif ($orderby == "reorder") {$db_orderby = "p.reorder_quantity";} elseif ($orderby == "reorder2") {$db_orderby = "p.products_reorder_to";} elseif ($orderby == "shelf") {$db_orderby = "p.shelf_pack";} elseif ($orderby == "cost") {$db_orderby = "p.vendors_product_price";} elseif ($orderby == "sku") {$db_orderby = "p.products_sku";} elseif ($orderby == "model") {$db_orderby = "p.products_model";} elseif ($orderby == "total") {$db_orderby = "total";} elseif ($orderby == "approved") {$db_orderby = "p.approved";$secsort=",total desc";} else {$db_orderby = "p.approved";$secsort=",total desc"; $sorted='DESC';} $products_query_raw = "select p.products_id, p.products_model, p.products_quantity, pd.products_name, p.products_sku, p.reorder_quantity, p.products_reorder_to, p.shelf_pack, p.vendors_product_price, pr.manufacturers_name,(p.vendors_product_price * p.products_reorder_to) as total, p.approved, p2c.categories_id from " . TABLE_PRODUCTS . " p inner join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id inner join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left outer join " . TABLE_MANUFACTURERS . " pr on p.manufacturers_id = pr.manufacturers_id where p.vendors2_id = 16 and pd.language_id = '" . $languages_id. "' group by pd.products_id order by $db_orderby $sorted $secsort"; $products_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_RESULTS, $products_query_raw, $products_query_numrows); $products_query = tep_db_query($products_query_raw); while ($products = tep_db_fetch_array($products_query)) { $rows++; if (strlen($rows) < 2) { $rows = '0' . $rows; } $products_id = $products['products_id']; $new_reorder_to = get_products_reorder_to($products['products_quantity'], $products['reorder_quantity'], $products['shelf_pack'], $products['products_reorder_to']); $subtotal = $new_reorder_to * $products['vendors_product_price']; $products_approved = tep_db_query("select approved from " . TABLE_PRODUCTS . " where products_id = $products_id"); $product_approved = tep_db_fetch_array($products_approved); $p_approved = $product_approved["approved"]; if($p_approved==1) $pagetotal += $subtotal; $approvedbutton = tep_draw_checkbox_field('add2order[]',$products_id,(($p_approved==1)? 'true':'')) . ' ' . (tep_not_null(ENTRY_NEWSLETTER_TEXT) ? '<span class="inputRequirement">' . 'Approved'. '</span>': ''); echo '<input type="hidden" name="add2orderlist[]" value="'.$products_id.'">'; ?> <tr class="dataTableRow"onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)"> <td align="left" class="dataTableContent"><?php echo $rows; ?>.</td> <td align="right" class="dataTableContent"><?php echo $products['products_sku']; ?></td> <td align="left" class="dataTableContent"><?php echo $products['products_model']; ?></td> <td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $products['categories_id'] . '&pID='.$products['products_id'].'&action=new_product') . '" TARGET="_blank"><b>' . $products['products_name'] . '</a></b>'; ?></td> <td align="right" class="dataTableContent"><?php echo $products['vendors_product_price']; ?></td> <td align="right" class="dataTableContent"><?php echo $products['shelf_pack']; ?></td> <td align="right" bgcolor="FFCCCC" class="dataTableContent"><?php echo $products['products_quantity']; ?></td> <td align="right" bgcolor="CCFF99" class="dataTableContent"><?php echo $products['reorder_quantity']; ?></td> <td align="right" width="50" class="dataTableContent"><?php echo tep_draw_input_field('reorder2['.$products_id.']', $new_reorder_to, 'style="width: 100%"'); ?></td> <td align="right" class="dataTableContent"><?php echo sprintf("%01.2f",$subtotal); ?></td> <td align="right" class="dataTableContent"><?php echo $approvedbutton; ?></td> </tr> <?php //} unset($cPath_array); unset($p_category_array); } ?> <tr class="dataTableHeadingRow"> <td class="dataTableHeadingContent" colspan="4" align="center"><input type="submit" name="reset" value="Send/Reset Order" onClick="return confirm('Send/Reset all orders?');"></td> <td class="dataTableHeadingContent" colspan="5" align="center"><input type="submit" name="save" value="Save Order" onClick="return confirm('Save orders?');"></td> <td class="dataTableHeadingContent" colspan="2"><?php echo 'Sub Total : $'.$pagetotal; ?></td> </tr> </table></td> </tr> </form> <tr> <td colspan="3"><table border="0" width="90%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td> <td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], "orderby=" . $orderby . "&sorted=" . $sorted); ?> </td> </tr> </table></td> </tr> </table></td> </tr> </table></td> <!-- body_text_eof //--> </tr> </table> </body> </html>
  6. Thanks for the reply & the code. It is the only query that uses this particular text file and this db table. And the only one producing errors in the data. The csv_reader is shared by a number of scripts, some of those were the ones getting goofed up because of un-escaped double quotes in the text. I can't figure out how or exactly where fgets fails where fgetcsv had no problem, but as a workaround I'm going to return to fgetcsv for this script only and try that.
  7. I made a couple of changes to a script that reads new data from a text file and updates mysql based on a field matching the text file. That field is $data_row[0] in the text file and products_sku in the following code. while (($data_row = $reader->getNextLine()) != NULL) { $products_sku = tep_db_prepare_input($data_row[0]); $products_model = $data_row[1]; //original $products_name = ucwords(strtolower($data_row[2])); $products_name = rtrim(ucwords(strtolower($data_row[8]))) . ' ' . rtrim(ucwords(strtolower($data_row[2]))) . ' ' . $data_row[1]; $products_width = $data_row[3]; //note there's a bunch more fields and the rest of the query // but this is the important part from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_sku = '" . $products_sku . "' and p.products_id = pd.products_id and pd.language_id = '1'"); What's happening is products that don't have a matching products_sku are being written over with all zeros in certain fields. The other part that I changed just before this problem appeared is this; class csv_reader { var $fp; function csv_reader($filename = '') { $this->fp = -1; if ($filename != '') { if (file_exists($filename)) { $this->fp = fopen($filename, "r"); } } } function getNextLine() { if ($this->fp == -1) return NULL; if (!feof($this->fp)) { $line = fgets($this->fp); return explode("~", $line); //original $arr = fgetcsv($this->fp, 0, "~"); //original return $arr; } else { fclose($this->fp); return NULL; } } } I changed from fgetcsv after reading http://php.net/manual/en/function.fgetcsv.php - post by jaimthorn at yahoo dot com I was having the same problem he described. Any thoughts on whether my code changes might be causing some fields to be written in all zeros where the products_sku is blank (not NULL, just blank).
  8. Thanks. I'm not sure how I got those odd quotes. I copied this from my personal notes blog (wordpress) Something else to look into.Thanks again!
  9. Sorry folks. It's been a long day, and none of it had to do with php. I have this code; $products_description = tep_db_prepare_input($data_row[1] . $data_row[2] . $data_row[3]); It "concats" I believe is the correct term, simply joins the data without adding spaces or anything else. I'm trying to duplicate that to a degree except I want to add html <br> between two datarows; $sql_data_array[‘products_description5′] = tep_db_prepare_input($data_row[4] ‘<br>’ $data_row[5]); or is it more like... $sql_data_array[‘products_description5′] = tep_db_prepare_input($data_row[4] . ‘<br>’ . $data_row[5]); Kinda running on empty here. I'm perfectly willing to find it myself. But what the heck would I search for?
  10. I'm still plugin away at this, still getting this error; Warning: ftp_fget() [function.ftp-fget]: Can't open data connection The script actually runs about 75 seconds just about every time. I tested manually and this file takes 4 seconds to download. I've tried ftp_get same result, ftp_nlist and ftp_rawlist and it still takes the same amount of time... Something isn't right. <?php ini_set('display_errors',1); error_reporting(E_ALL); // define some variables $folder_path = "/home/name/public_html/test/"; $local_file = "file.txt"; // $server_file = "file.txt"; //-- Connection Settings $ftp_server = "msserver"; // Address of FTP server. $ftp_user_name = "u"; // Username $ftp_user_pass = "p"; // Password // set up basic connection $conn_id = ftp_connect($ftp_server); // I checked, port is 21 // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); ftp_pasv($conn_id, true); if(ftp_chdir($conn_id, "folder/webfiles/")) { echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; } // ftp_pasv($conn_id, true); $lf = fopen($local_file, 'w'); if (!$lf){ die('Failed to create local file.'); } if (!ftp_fget($conn_id, $lf, $server_file, FTP_ASCII)) { die('Failed to download file from FTP server.'); } // ftp_get($conn_id, $local_file, $server_file, FTP_ASCII); // close the connection ftp_close($conn_id); fclose($lf); ?>
  11. Thanks again! But I'm still stuck though; Warning: ftp_fget() [function.ftp-fget]: Can't open data connection. Most of what I'm finding on this is the ftp_pasv that you suggested and I'm already using. It's not a time out issue even though this script runs for about 2-3 minutes, this is the smallest file of the group of 9 text files I need to deal with. Same results whether I use the ftp.name or ip Same also whether its ascii or binary.
  12. Makes perfect sense, only my method doesn't seem to work. Pretty much anywhere I've tried it. <?php ini_set('display_errors',1); error_reporting(E_ALL); // define some variables $folder_path = "/home/name/public_html/test/"; $local_file = "file.txt"; $server_file = "file.txt"; //-- Connection Settings $ftp_server = "ftp.msserver.com"; // Address of FTP server. $ftp_user_name = "u"; // Username $ftp_user_pass = "p"; // Password #$destination_file = "FILEPATH"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if(ftp_chdir($conn_id, "/folder/webfiles/")) { echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; }else{ echo "Couldn't change directory\n"; } $lf = fopen($local_file, 'w'); if (!$lf){ die('Failed to create local file.'); } if (!ftp_fget($conn_id, $lf, $server_file, FTP_ASCII)) { die('Failed to download file from FTP server.'); } fclose($lf); // close the connection ftp_close($conn_id); ?> Here's what I'm getting; Current directory is now: /folder/webfiles Warning: ftp_fget() [function.ftp-fget]: Opening ASCII mode data connection for skudescadd.txt(216014 bytes). in /home/name/public_html/test/cron_transfer_texts.php on line 26 Failed to download file from FTP server.
  13. Thanks, that's moving closer. Now I know it's about changing directories on the remote server.
  14. I guess I need some help here. This is going to be cron job once I get it going. The source server is Microsoft-IIS/7.5 (we're getting pretty large text files that are in a directory. I.E. in manual ftp you need to cd /folder/webfiles/) The destination server is Apache/2.2.17 (Unix) PHP/5.2.9 File & folder permissions set to 777 So this is what I've been getting; Warning: ftp_get(file.txt) [function.ftp-get]: failed to open stream: Permission denied in /home/name/public_html/cron_transfer_texts.php on line 36 Warning: ftp_get() [function.ftp-get]: Error opening file.txt in /home/name/public_html/cron_transfer_texts.php on line 36 (Line 36 is the ftp_get) I wasn't sure if I had a connection or not so I tried; // get contents of the current directory $contents = ftp_nlist($conn_id, "/folder/webfiles/"); // output $contents var_dump($contents); It sat there and chewed on it for several minutes, but just finished without putting anything on the screen. Then I tried this; if (!($type = ftp_systype($conn_id))) { echo "FTP connection has failed! Trying again.\n"; $conn_id = ftp_connect($ftp_server); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); }else{ echo ("Nothing to report");} and all I get is; Nothing to report <?php ini_set('display_errors',1); error_reporting(E_ALL); // define some variables $folder_path = "/home/name/public_html/test"; //test is a directory 777 $local_file = "file.txt"; $server_file = "file.txt"; //-- Connection Settings $ftp_server = "ftp.msserver.com"; // Address of FTP server. 00.000.000.000 //tried name & ip same results $ftp_user_name = "username"; // Username $ftp_user_pass = "password"; // Password #$destination_file = "FILEPATH"; // set up basic connection $conn_id = ftp_connect($ftp_server) or die("did not connect"); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to download $server_file and save to $local_file // must be either FTP_ASCII or FTP_BINARY if (ftp_get($conn_id, $local_file, $server_file, FTP_ASCII)) { if ((!$conn_id) || (!$login_result)) { die("FTP connection has failed !"); } echo "Current directory: " . ftp_pwd($conn_id) . "\n"; // try to change the directory to somedir if (ftp_chdir($conn_id, "folder/webfiles")) { echo "Current directory is now: " . ftp_pwd($conn_id) . "\n"; } else { echo "Couldn't change directory\n"; } echo "Successfully written to $local_file\n"; } else { echo "There was a problem\n"; } // close the connection ftp_close($conn_id); ?>
  15. Thanks Jessica, two single quotes works just fine. Helped me weed out another 4500 products we can't actually sell.
×
×
  • 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.