Jump to content

js_280

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

js_280's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've been trying to figure out what's wrong with this code for several days now... Running PHP 5.8 on Windows Server 2003 The pdf files are being created correctly, I can go open them with Adobe without a problem. The problem comes when the script attempts to add the pdf file as an attachment. Something is apparently messing with the headers because the pdf file is simply dumped into the email as plain text. Can anyone see something that I've missed? I found the code on devshed and thought it would port over without problem... try { $pdf->end_document(""); $buf = $pdf->get_buffer(); $len = strlen($buf); $filename = rand(0, getrandmax()).".pdf"; file_put_contents($filename, $buf); $to = $branches[$i]['email']; //define the subject of the email $subject = 'Automated Collection Letters for Branch '.$branches[$i]['num']; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: admin@somwhere.com\r\nReply-To: admin@somewhere.com"; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\""; //read the atachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($filename))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>" --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: application/pdf; name="<?php echo($filename); ?>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email mail('someone@somewhere.com', $subject, $message, $headers); } catch(Exception $e) { } This is what I'm getting in the body of the email...
  2. The vendor exports their database via ODBC into MySQL... Anyway...here's what I came up with... SELECT table.Qty, IF(table.Qty REGEXP '-$', (CAST(table.Qty AS DECIMAL) * -1), CAST(table.Qty AS DECIMAL)) AS real_number from table; Probably overly complicated, but it worked...
  3. I have a program that exports columns into a MySQL varchar column. The vendor exports numbers and strings into this column. I'm only pulling the fields that have numbers in them and casting them as decimals. The problem I'm running into is that when the vendor exports the negative numbers, the negative sign comes after the number instead of before and is causing the number to add instead of subtract when SUM()'ng. Any ideas?
  4. I've attempted to try my hand at using PHP and COM in Windows, however I cannot seem to get any of the objects to become visible. For example the following script will not display Excel... $excel = new COM('Excel.Application') or die('Cannot start Excel'); $excel->Visible = true; This script starts an Excel process in task manager, but will not display the program. I've looked through all of my IIS settings and "Allow Service to Interact with Desktop" is checked. I'm at a loss, because if is run this statement... echo($excel->Version); It displays 11.0 which is the version of Excel I am running... Any ideas or suggestions? Something I've overlooked?
  5. Works under my Firefox with substituted url. Use Firebug extension on Firefox to see if you're getting a reply from your script.
  6. js_280

    Slow Query...

    I want to be able to get all customers using the criteria specified without having the customer listed multiple times simply because they have multiple tanks tied to their location. Without the DISTINCT statement, I would get approximately 30,000 duplicates.
  7. js_280

    Slow Query...

    ID's are unique, however there can be multiple tanks tied to each location, and will add duplicates. Indexes: mysql> show indexes from customerfile \G; *************************** 1. row *************************** Table: customerfile Non_unique: 1 Key_name: comp_index Seq_in_index: 1 Column_name: CustomerCompanyNumber Collation: A Cardinality: 90 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 2. row *************************** Table: customerfile Non_unique: 1 Key_name: account_index Seq_in_index: 1 Column_name: CustomerNumber Collation: A Cardinality: 296830 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: 2 rows in set (0.00 sec) mysql> show indexes from locationfile \G; *************************** 1. row *************************** Table: locationfile Non_unique: 1 Key_name: locationIDX Seq_in_index: 1 Column_name: LocationCustomerNumber Collation: A Cardinality: 301336 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 2. row *************************** Table: locationfile Non_unique: 1 Key_name: productcodeIDX Seq_in_index: 1 Column_name: LocationProductCategory Collation: A Cardinality: 56 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: *************************** 3. row *************************** Table: locationfile Non_unique: 1 Key_name: location_company Seq_in_index: 1 Column_name: LocationCompanyNumber Collation: A Cardinality: 91 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 4. row *************************** Table: locationfile Non_unique: 1 Key_name: location_locationnumber Seq_in_index: 1 Column_name: LocationNumber Collation: A Cardinality: 1969 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: 4 rows in set (0.00 sec) mysql> show indexes from tankfile \G; *************************** 1. row *************************** Table: tankfile Non_unique: 1 Key_name: tank_cust_index Seq_in_index: 1 Column_name: TankChargeToCustomer Collation: A Cardinality: 169650 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 2. row *************************** Table: tankfile Non_unique: 1 Key_name: serial_index Seq_in_index: 1 Column_name: TankSerialNo Collation: A Cardinality: 169650 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: *************************** 3. row *************************** Table: tankfile Non_unique: 1 Key_name: tank_company Seq_in_index: 1 Column_name: TankCompanyNumber Collation: A Cardinality: 91 Sub_part: NULL Packed: NULL Null: Index_type: BTREE Comment: *************************** 4. row *************************** Table: tankfile Non_unique: 1 Key_name: rental_tank Seq_in_index: 1 Column_name: TankRentalTank Collation: A Cardinality: 3 Sub_part: NULL Packed: NULL Null: YES Index_type: BTREE Comment: 4 rows in set (0.00 sec)
  8. js_280

    Slow Query...

    15.075 seconds without where clauses... SELECT distinct sqlar001.customerfile.customernumber, sqlar001.customerfile.customercompanynumber, sqlar001.customerfile.CustomerStatementName, sqlar001.locationfile.locationnumber FROM sqlar001.customerfile inner join sqlar001.locationfile on sqlar001.customerfile.customernumber = sqlar001.locationfile.locationcustomernumber AND sqlar001.customerfile.customercompanynumber = sqlar001.locationfile.locationcompanynumber inner join sqlar001.tankfile on sqlar001.customerfile.customernumber = sqlar001.tankfile.tankchargetocustomer and sqlar001.customerfile.customercompanynumber = sqlar001.tankfile.tankcompanynumber; [attachment deleted by admin]
  9. js_280

    Slow Query...

    There is a non-unique index on customerfile.customernumber, locationfile.locationcustomernumber, customerfile.customercompanynumber, locationfile.locationcompanynumber, tankfile.tankcompanynumber, and each column specified in the "Where" statement. If != and NOT IN() are bad for performance, what are the other options beside listing everything I do need? I have 355 stores and simply need to exclude two of them for reporting purposes. Would it be faster performance-wise to use a sub-select than != ?
  10. How are you initiating the XMLHTTP object? myRequest = new XMLHttpRequest(); // For Firefox myRequest = new ActiveXObject('Microsoft.XMLHTTP'); // Two quick versions for IE myRequest = new ActiveXObject('Msxml2.XMLHttp');
  11. <?php $con = mysql_connect("database host", "username", "password"); $query = "SELECT col_1, col_2, col_3 FROM table"; $result = mysql_query($query, $con); while($data = mysql_fetch_array($result)) { echo($data['col_1'].' '.$data['col_2'].' '.$data['col_3'].'<br />'); } ?> You'll have to substitute your database login information, column names, and table name of course...
  12. It's a list of variables passed using the "GET" method... Check out this wikipedia link http://en.wikipedia.org/wiki/Query_string
  13. Change your script to: $query = "SELECT sed_statistics.status, COUNT(sed_statistics.id) AS my_count FROM sed_statistics LEFT JOIN equivalences ON sed_statistics.status = equivalences.equiv GROUP BY sed_statistics.status ORDER BY sed_statistics.status ASC LIMIT 0, 30"; $result = mysql_query($query) or die(mysql_error()); // Print out the contents of each row into a table while($row = mysql_fetch_array($result)) { echo $row['status']; echo " "; echo $row['my_count']; }
  14. SELECT * FROM file_items LEFT JOIN files ON file_items.id = files.id WHERE files.type = "needed type here" ORDER BY file_items.view DESC LIMIT 0, 1
  15. Ooops... make that <select name='category'> <? $artcat = mysql_query("SELECT * FROM artcat ORDER BY id DESC",$db); while ($artcat_data = mysql_fetch_array($artcat)) { $artcat_id=$artcat_data["id"]; $artcat_title=$artcat_data["title"]; if($artcat_id == $category) { echo('<option value="'.$artcat_id.'" selected="selected">'.$artcat_title.'</option>'); } else { echo('<option value="'.$artcat_id.'">'.$artcat_title.'</option>'); } } ?> </select>
×
×
  • 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.