Jump to content

dmikester1

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by dmikester1

  1. Thank you. I changed the way I was inserting in the array. I knew there had to be an easier way than what I was doing, but was having a brain fart or something. Thanks!
  2. I'm having some troubles with this one. I set up my array like so: $POs[] = array( $jobID=>array( 'FSME' => $matTotal, 'FSMC' => $matTotal, 'FSDE' => $draftingTotal, ... And say $jobID is equal to 312. Now I am trying to access one of those values. I tried: $POs[$jobID]['FSME'] with $jobID being 312. Then I get "Notice: Undefined offset: 312 in..." Any ideas how I can access this variable? Thanks Mike
  3. I can't figure out how to remove a specific item from my array by key. Array: $uncachedSites = array(2=>'site 1', 3=>'site 2', 4=>'site 3', 5=>'site 4'); So I'm running through a loop with $i starting at 2 and going up to 5. If I say unset($uncachedSites[$i], the first time around I'm thinking it will remove 'site 3' instead of 'site 1' like I want it to. But I can't figure out how to remove the first one without just saying unset($uncachedSites[0]) Thanks Mike
  4. Well, the second argument passed to array_map needs to be an array and that long id number is obviously not an array.
  5. It appears that argument 2 of array_map is not an array. When you do this: "print_r ($_POST['need_delete']);", what do you get?
  6. I assume you are setting $prog2_menu and $prog1_menu from the GET variables earlier in your PHP code? You really need to learn to use some CSS. This is UGLY! echo " Ascending bass line";
  7. I just had to do this earlier today. This is what worked for me. This works for multiple files. Mike if(isset($_FILES['uploadFiles']['name'])) { foreach ($_FILES['uploadFiles']['name'] as $i => $name) { if ($_FILES['uploadFiles']['error'][$i] == 4) { continue; } if ($_FILES['uploadFiles']['error'][$i] == 0) { if ($_FILES['uploadFiles']['size'][$i] > 99439443) { $messages[] = "$name exceeded file limit."; continue; } if(move_uploaded_file($_FILES['uploadFiles']['tmp_name'][$i], "uploads/$name")) { $uploaded++; $files[] = "uploads/$name"; } else { echo "Could not upload $name to be attached!<br />"; } } } //$files = $_FILES['uploadFiles']['tmp_name']; } echo "$uploaded receipt"; if($uploaded != 1) { echo "s"; } echo " uploaded."; foreach ($messages as $error) { echo $error; } // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $eol = PHP_EOL; $headers = "From: ".$to.$eol; $headers .= "Reply-To: ".$to.$eol; $subject = "Expense Report - Period Ending $reportDate"; $headers .= $eol."MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol; // no more headers after this, we start the body! // //$body = "--".$mime_boundary.$eol; //$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $body .= "This is a multi-part message in MIME format.".$eol; // message $body .= "--".$mime_boundary.$eol; $body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol; $body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $body .= $message.$eol.$eol; if($uploaded > 0) { // if there are attachments add this line to the message, otherwise with no attachments this line will add an unwanted attachment //$body .= "--{$mime_boundary}\n"; } if(isset($_FILES['uploadFiles']['name'])) { // preparing attachments for($x=0;$x<count($files);$x++){ $file = fopen($files[$x],"rb"); $data = fread($file,filesize($files[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $name = $_FILES['uploadFiles']['name'][$x]; /*$body .= "–{$mime_boundary}\n"; $body .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; //$body .="--{$mime_boundary}--\n"; if ($x==count($files)-1) { //$message .="--{$mime_boundary}-\n"; } else{ //$message .="--{$mime_boundary}\n"; }*/ // attachment $body .= "--".$mime_boundary.$eol; $body .= "Content-Type: application/octet-stream; name=\"".$name."\"".$eol; $body .= "Content-Transfer-Encoding: base64".$eol; $body .= "Content-Disposition: attachment".$eol.$eol; $body .= $data.$eol.$eol; } $body .= "--".$mime_boundary."--"; } // send $ok = @mail($to, $subject, $body, $headers); if ($ok) { echo "<p>Email sent to $to!</p>"; } else { echo "<p>Email could not be sent!</p>"; } }
  8. WHERE live = 1 AND title LIKE \"%$term%\" OR description LIKE \"%$term%\" What do you want here? WHERE (live = 1 AND title LIKE \"%$term%\") OR description LIKE \"%$term%\" - or - WHERE live = 1 AND (title LIKE \"%$term%\" OR description LIKE \"%$term%\") Notice the change in parens. Mike
  9. I assume eventually there will be much more than 2 lines in the text file? Instead of writing to a text file, it would be much more robust and easier to sort by adding the entries to a mysql database.
  10. Do you have some starting code to help us out? I don't think many people here are willing to write the whole thing for you.
  11. Sounds like something you could do with javascript/jquery/ajax. I'm not sure if that is possible with just PHP though. Unless they select the first dropdown and hit a submit button, but that would be cumbersome for the user. Someone correct me if I am wrong. Mike
  12. Heh, figured this one out on my own. Turns out for my situation, I had to do a "move_uploaded_file" to a folder in my web root for it to work. Maybe this isn't always the case, but it fixed my problem. I also had to move the last "$body .= "--".$mime_boundary."--";" outside of the for loop to get it to work with multiple files. Maybe this will help someone else out.
  13. Do I have to move the uploaded file to a permanent location or can I just use the 'tmp_name' to email it?
  14. I need some help with emailing an uploaded file. The file is always corrupted and just a few bytes, when it is normally a few KB. I would prefer not to use the PHP mailer class so I can learn myself how to do the coding. Thanks Mike Here is the relevant code: $uploaded = 0; $messages = array(); if(isset($_FILES['uploadFiles']['name'])) { foreach ($_FILES['uploadFiles']['name'] as $i => $name) { if ($_FILES['uploadFiles']['error'][$i] == 4) { continue; } if ($_FILES['uploadFiles']['error'][$i] == 0) { if ($_FILES['uploadFiles']['size'][$i] > 99439443) { $messages[] = "$name exceeded file limit."; continue; } $uploaded++; } } $files = $_FILES['uploadFiles']['tmp_name']; } echo "$uploaded receipt"; if($uploaded != 1) { echo "s"; } echo " uploaded."; foreach ($messages as $error) { echo $error; } // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $eol = PHP_EOL; $headers = "From: ".$to.$eol; $headers .= "Reply-To: ".$to.$eol; $subject = "Expense Report - Period Ending $reportDate"; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol; // no more headers after this, we start the body! // //$body = "--".$mime_boundary.$eol; //$body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $body .= "This is a multi-part message in MIME format.".$eol; // message $body .= "--".$mime_boundary.$eol; $body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol; $body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $body .= $message.$eol.$eol; if($uploaded > 0) { // if there are attachments add this line to the message, otherwise with no attachments this line will add an unwanted attachment //$message .= "--{$mime_boundary}\n"; } if(isset($_FILES['uploadFiles']['name'])) { // preparing attachments for($x=0;$x<count($files);$x++){ $file = fopen($files[$x],"rb"); $data = fread($file,filesize($files[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $name = $_FILES['uploadFiles']['name'][$x]; /*$body .= "–{$mime_boundary}\n"; $body .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$name\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$name\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; //$body .="--{$mime_boundary}--\n"; if ($x==count($files)-1) { //$message .="--{$mime_boundary}-\n"; } else{ //$message .="--{$mime_boundary}\n"; }*/ // attachment $body .= "--".$mime_boundary.$eol; $body .= "Content-Type: application/octet-stream; name=\"".$name."\"".$eol; $body .= "Content-Transfer-Encoding: base64".$eol; $body .= "Content-Disposition: attachment".$eol.$eol; $body .= $data.$eol.$eol; $body .= "--".$mime_boundary."--"; } } // send $ok = @mail($to, $subject, $body, $headers); if ($ok) { echo "<p>email sent to $to!</p>"; } else { echo "<p>email could not be sent!</p>"; } } ?>
  15. I have a PHP script that does some work copying some files and parsing through the files. Then it creates an Excel file and sends it to the browser to download. So you user will see the standard popup asking to save or open the file. Well, I am using ob_flush to try and output text to the browser while it is working so the user knows something is happening. But whenever I add the ob_flush lines in, it just sends a bunch of garbage text to the browser instead of downloading the file. Anyone know a way around this? Thanks Mike
  16. Sweet! That worked perfectly. Thank you very much! Mike
  17. I did try the extractTo method and it was extracting the files into a subfolder of the name of the zip file. I want them extracted without that subfolder.
  18. I'm trying to extract the contents of a zip file to a folder. I found the ZipArchive class and followed the examples to get it to work for the most part. But I want to extract the files in the folder inside the zip file but leave the folder out. So it should extract just the files to my given destination. I found this on php.net. If you want to copy one file at a time and remove the folder name that is stored in the ZIP file, so you don't have to create directories from the ZIP itself, then use this snippet (basically collapses the ZIP file into one Folder). <?php $path = 'zipfile.zip' $zip = new ZipArchive; if ($zip->open($path) === true) { for($i = 0; $i < $zip->numFiles; $i++) { $filename = $zip->getNameIndex($i); $fileinfo = pathinfo($filename); copy("zip://".$path."#".$filename, "/your/new/destination/".$fileinfo['basename']); } $zip->close(); } ?> For some reason that 'copy' line is not working for me. Obviosly I've changed the variables in the line to the correct variables. Can someone help me out. Thanks Mike
  19. So this line is failing? if (file_exists($imagesource)) {
  20. Why do you need seperate variable names? Will an array work? item[0], item[1], item[2]... Thanks Mike
  21. Can we assume you know how to get that "first character" from an input box on a web page into a PHP variable? Or are you asking how to do that as well? Mike
  22. I believe the 'value' value is optional for the <option> tag. I believe it gets automatically set to what is between the <option> tags when the data is posted. Mike
  23. Jamied_ui, I would recommend starting your own thread asking very specifically what you are looking for help with. And also indicate what you have tried so far. Mike
  24. Adding to scootsah's code: SELECT t1.title, t2.* FROM table1 AS t1 JOIN table2 AS t2 ON t2.mpid = t1.mpid WHERE t1.mpid = '2' BTW, this is a MySQL question, not a PHP question.
  25. I always thought the type value and the name value had to be in quotes like so: <input type='hidden' name='CODE' value='03'> Not sure if that will fix it or not. Mike
×
×
  • 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.