Jump to content

dudejma

Members
  • Posts

    161
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dudejma's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Every time I try to use str_replace, I always mess something up. Thanks!
  2. I have read the PCRE page on PHP and I still don't understand. All I'm trying to do is simply remove the letters from this variable. I have a variable, for example "555tul,748den". I simply want to remove the letters, but keep the comma. Everywhere I've looked, all the examples remove the letters but remove the comma too. I need to keep the comma. Any suggestions? Much appreciated.
  3. dudejma

    mail()

    I'm trying to send mail with an attachment and it doesn't even try to send it. I'm not very experienced with mail or attachments, this is the first script with attachments I have every used. I'm not sure if I did it all right or not because I read a tutorial on it. Here's the code: if (isset($_POST['submit'])) { $getPilots = "SELECT * FROM users WHERE emailOption = '1' AND status = '1'"; $runGetPilots = mysql_query($getPilots); $emails_arr = array(); $info = mysql_fetch_array($runGetPilots); $emails_arr[] = $info['email']; $to = implode(', ', $emails_arr); $subject = $_POST['subject']; $message = stripslashes($_POST['message']); $fileName = $_POST['newsletter']; $fileType = substr($fileName, strlen($fileName)-4, strlen($fileName)); $contents = chunk_split(base64_encode(file_get_contents("../newsletter/$fileName"))); $uid = md5(uniqid(time())); $headers = "MIME-Version: 1.0\r\n"; $headers .= "From: Virtual American <noreply@virtualamerican.org>\r\n"; $headers .= "Reply-To: Virtual American <noreply@virtualamerican.org>\r\n"; $headers .= "Return-Path: Virtual American <noreply@virtualamerican.org>\r\n"; $headers .= "X-Mailer: PHP". phpversion() ."\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $headers .= "This is a multi-part message in MIME format.\r\n"; $headers .= "--".$uid."\r\n"; $headers .= "Content-type:text/plain; charset=iso-8859-1\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $headers .= $message."\r\n\r\n"; $headers .= "--".$uid."\r\n"; $headers .= "Content-Type: ".$fileType."; name=\"".$fileName."\"\r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; filename=\"".$fileName."\"\r\n\r\n"; $headers .= $contents."\r\n\r\n"; if (!mail($to,$subject,"",$headers)) { $errors .= "There was an error sending the email(s). Please contact the webmaster. <br />"; error_log("The mail didn't work!",0); } else { header("Location: ac.php?message=1"); } } else {} I'm sure there is more to include, but I'm not exactly sure what, maybe the form? <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" cellpadding="6" cellspacing="6"> <tr> <td><b>Subject: </b></td> <td><input type="text" name="subject" value="<?php echo $_POST['subject']; ?>" size="24" maxlength="70" /></td> </tr> <tr> <td><b>Message: </b></td> <td><textarea cols="40" rows="20" name="message"><?php echo $_POST['message']; ?></textarea></td> </tr> <tr> <td><b>Newsletter: </b></td> <td><select name="newsletter"> <?php $handle = opendir("../newsletter"); while (false !== ($entry = readdir($handle))) { if ($_POST['newsletter'] == $entry) { $selected = 'selected="selected"'; } else { $selected = ""; } if ($entry != "." && $entry != "..") { echo '<option value="' . $entry . '" $selected>' . $entry . '</option>'; } } echo '</select>'; ?>
  4. I keep getting the "Invalid arguments passed in..." error when trying to use implode. Here's the code: $getPilots = "SELECT * FROM users WHERE emailOption = '1' AND status = '1'"; $runGetPilots = mysql_query($getPilots); while ($info = mysql_fetch_array($runGetPilots)) { $emails = $info['email']; $to = implode(', ', $emails); The ending bracket is there, i just didn't include it in the code. Any suggestions? Thanks.
  5. <form action="takeAttendance1.php" method="post"> <table> <tr> <th>Name</th> <th>Mark</th> </tr> <tr> <?php echo '<td>' . $row['lastName'] . ', ' . $row['firstName'] . '</td>'; echo '<td><input type="text" name="' . $row['id'] . '"></td>'; ?> </tr> </table> <input type="submit" value="Enter Attendance"> </form>
  6. I have this form. The name of the field is an id of a row in a table. When the user inputs the information into the field, it goes to another page that processes the information. This is the code on the page that processes it: while ($ids = mysql_fetch_array($getIDs) { $staffID = $ids['id']; //id is the column name in my table $value = $_POST['$staffID']; But when I echo $value, it doesn't echo anything. I have made sure that there is a value in the field and if, instead of $_POST['$staffID'], I type a specific ID such as, $_POST['55485'], it will output the value entered in that field. I have not yet grasped the concept of arrays yet so that's why I'm not using one here. Can you just not put a variable in $_POST? Thanks.
  7. It counts how many records are in the table and divides it by the number of items per page, then it rounds it.
  8. The code for the drop down: echo '<select name="select" ONCHANGE="goto(this.form)">'; while ($dropDown > 0) { if ($page == $dropDown) { $selected = 'selected="selected"'; } else { $selected = ""; } echo "<option value=\"searchFlights.php?page=" . $dropDown . "\" $selected>" . $dropDown . "</option>"; $dropDown = $dropDown - 1; } echo '</select>'; It works fine, but I want 1 to be at the top of the list and go down from there because right now, it starts with the biggest number and goes down. Any suggestions? Thanks!
  9. It works, thanks guys!
  10. I'm not very advanced, but isn't offset the same thing as the second number in limit? Ex.: "LIMIT 0, 30" - Would 30 be the offset, or do you have to do; "LIMIT 0 OFFSET 30"?
  11. Oh, that makes sense. Thanks!
  12. Is there a way of doing pagination other than going through the whole big file, like: $limit = "LIMIT 0, 30"; if ($_GET['page'] == 2) { $limit = "LIMIT 30, 30"; } $sql = "SELECT * FROM table WHERE blah = 'blah' $limit"; $result = mysql_query($sql); But is there a way to do this without having to write an if statement for each page without getting to extensive? Thanks!
  13. I figured it out. I guess the server side gets confused when it takes a decimal already formatted with number_format directly from the database. Thanks for the help guys!
  14. No, I want it to take $oldPay or the amount the pilot already has, and add the $newPay or the amount given for completion of the flight.
×
×
  • 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.