Jump to content

jpratt

Members
  • Posts

    144
  • Joined

  • Last visited

    Never

Everything posted by jpratt

  1. I am looking for examples in ziping a folder. Does anyone have examples of doing this? I have seen code to sip one file into a .zip file but not taking an entire folder with subdirectories and making it a zip. Any links or code samples would be helpful, thanks.
  2. Im using phpmailer to send email via a pop3 account using SMTP authentication. I am using the following code: $pop = new POP3(); $pop->Authorise('mail.ess-med.com', 110, 30, 'myusername', 'mypassword', 1); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = 2; $mail->IsHTML(true); $mail->Host = 'mail.ess-med.com'; $mail->From = 'report@ess-med.com'; $mail->FromName = 'Pet Information Report'; $mail->Subject = 'Report for ' . $pname; $mail->Body = $msg; $toemail = $_POST['toemail']; $mail->AddAddress('test@arcticsoft.net'); if (!$mail->Send()) { echo $mail->ErrorInfo; } I can send email to addresses on the same domain but not outside of it. Any ideas why? Please help.
  3. Thanks for the help but that gives me the desination wich is not the problem, I am trying to get the entire source path to copy from. When I do $_FILES['userfile']['name'] it gives me the source filename but nothing before it? is there a way to get the entire source destination?
  4. I am using $_FILES['userfile']['name'] to get a name of a file to copy from a users machine to place on a thumb drive. The user is basically copying the file from a local path to a local path using a portable version of php on their own comp. How do i get the path for copying the file? I have a form with enctype="multipart/form-data". How can i get the source path?
  5. all pdf classes ive worked with make you call the newpage method for each new page to be created. This only has it called once outside of your loop so it should only create one page.
  6. anyway of tagging what has been searched so in the next iteration it is not selected? any help appreciated.
  7. Check your permissions on your folder and your php.ini file to make sure you have file uploads on.
  8. so now this is what I have: $matched = false; for ($zippos = 5; $zippos > 0 && !$matched; $zippos--) { $userzip = substr($zipin, 0 ,$zippos); $sqlwsearch = "SELECT * FROM whitepage WHERE SUBSTRING(Zip, 1, '$zippos') = '$userzip'"; $resultw = mysql_query($sqlwsearch); while ($row = mysql_fetch_array($resultw)) { if ((substr($row['Zip'], 0, $zippos)) == $userzip) { $matched = true; echo "<p><table id='white'><tr><td id='company'>" . $row['CompanyName'] . "</td></tr>"; echo "<tr><td>" . $row['Address'] . "</td></tr>"; echo "<tr><td>" . $row['City'] . ", " . $row['State'] . " " . $row['Zip'] . "</td></tr>"; echo "<tr><td>http://www." . $row['WebLink']. "</td></tr></table></p>"; } } } it is now returning the results of the matches up to the first 2 characters of the zip. so I have the zip codes of 80016, 84372, 84532, and 87824. If i search for 84125 it returns the two starting with 84. Any ideas why it is not returning the other two?
  9. I am doing a zipcode search so it is looping through and first finding the records that match the user zipcode, then searching the match of the first four of the zip, then the first 3 and so on. Here is how i am doing it: $zippos = 5; while ($zippos > 0) { $userzip = substr($zipin, 0 ,$zippos); $sqlwsearch = "SELECT * FROM whitepage WHERE SUBSTRING(Zip, 1, '$zippos') = '$userzip'"; $resultw = mysql_query($sqlwsearch); $numrows = mysql_num_rows($resultw); //display results here $zippos--; } My question is how do I get it not to repeat results that match each loop through? if I have a zip in the database of 12345 and i search 12347, I dont want it repeated 4 times in my results. Any ideas?
  10. any ideas? i got the value of $_POST['1'] and it was random either not set or was "Add". really weird.
  11. I have a form with html: <?php echo "<form id='form1' enctype='multipart/form-data' name='form1' method='post' action='attach2.php'>"; $sql = "SELECT * FROM attachments"; $prepstatement = $db->prepare($sql); $prepstatement->execute(); while($row = $prepstatement->fetch()) { echo "<tr style='font-size:11px;'>\n"; echo "<td><input type='checkbox' name='idnum[]' value='" . $row['attachID'] . "' />\n"; echo "<td>" . $row['attachname'] . "</td>\n"; echo "<td colspan='2'>" . $row['description'] . "</td>\n"; echo "<td><a style='color:#000099; text-decoration:underline;' href='attachments/" . $row['location'] . "'>" . $row['location'] . "</a></td></tr>\n"; } unset($sql, $prepstatement); ?> <tr height="25"><td></td></tr> <tr> <td colspan="2"><strong><font size="2">Name:</font></strong></td> <td colspan="3"><?php echo "<input name='name' type='text' />"; ?> </td> </tr> <tr> <td colspan="2"><strong><font size="2">File:</font></strong></td> <td colspan="3"> <?php echo "<input name='userfile' type='file' />"; ?> </td> </tr> <tr> <tr> <td colspan="2"><strong><font size="2">Description:</font></strong></td> <td colspan="3"> <?php echo "<textarea name='description' cols='35' rows='4'></textarea>"; ?> </td> </tr> <tr> <td colspan="2"><div align="right"> <?php echo "<input style='background-color:#C8DAE8;' type='submit' name='1' id='button' value='Add' />"; ?> </div></td> <td colspan="3"><?php echo "<input type='submit' name='2' id='button5' value='Remove' />"; ?></td> </tr><?php echo "</form>"; ?> and on the attach2.php file looks like this: <?php require_once('db/config.php'); if ($_POST['1'] == 'Add') { //ghfgh $name = $_POST['name']; $description = $_POST['description']; $currentdir = $_SERVER["DOCUMENT_ROOT"]."/"; $currentdir = str_replace ("/", "\\", $currentdir); $currentdir = str_replace ("www\\localhost\\", "", $currentdir); $uploadtempdir = $currentdir . "temp/"; ini_set('upload_tmp_dir', $uploadtempdir); $uploaddir = "attachments/"; $filename = $_FILES['userfile']['name']; $uploadfile = $uploaddir . $_FILES['userfile']['name']; move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile); //dfghf $sql = "INSERT INTO attachments (attachname, location, description) VALUES ('$name', '$filename', '$description')"; $prepstatement = $db->prepare($sql); $prepstatement->execute(); } if ($_POST['2'] == 'Remove') { foreach($_POST['idnum'] as $remove) { $sql = "SELECT location FROM attachments WHERE attachID = '$remove'"; $prepstatement = $db->prepare($sql); $prepstatement->execute(); while($row = $prepstatement->fetch()) { $unlink = "attachments/" . $row['location']; unlink($unlink); } unset($sql, $prepstatement); $sql = "DELETE FROM attachments WHERE attachID = '$remove'"; $prepstatement = $db->prepare($sql); $prepstatement->execute(); } } header('Location:attach.php'); ?> The problem is it works on the first post, but after it goes back to attach.php and i hit add it think for a minute like it is doing the upload, then refreshes and does nothing. then if i upload again it works sometimes seems to be very random. I do not understand why it is so random in working. It nevers thows and error, just either works or not. Please help.
  12. no, im still getting an error when a ' is entered. I tried using addslashes but still get the error. addslashes worked for " but not '
  13. I tried addslashes, but it still gives an error when using ' but works fine inserting "
  14. $comment = $_POST['comment']; $sql = "INSERT INTO medjournal (comment) VALUES ('$comment')"; Here is a sample. I cannot use mysql_real_escape_string as i am using a sqlite db using pdo. Can anyone give me an example using this bit of code? Thanks.
  15. I have quite a few field where the user may type in a' or a ". how do I format the string so it inputs it into the database appropriately? Thanks.
  16. I am writing some software and they want a way to protect the software from being copied. Is there a way to tell if a file way copied? It a program that runs on a thumb drive, and I don't want people buying the drive and just copying it to all their friends drives as well. Is there such a function in php?
  17. nope didnt work. I still get the error. Any ideas?
  18. is the tilde'~' sapose to be in there? I tried it and it did not fix the errors.
  19. Here is my form: [code] <form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">           <?php if($HTTP_POST_FILES['File_Name']['size'] > 0 && file_exists("../owner/files/".$HTTP_POST_FILES['File_Name']['name'])) { ?><p class="CaptionText">File name already in use, change file name or delete file off server!</p>           <?php } ?>           <table align="center">             <tr valign="baseline">               <td nowrap align="right">File Name:</td>               <td>              <input name="File_Name" type="file" class="inputbox" id="File_Name"></td>             </tr>             <tr valign="baseline">               <td colspan="2" align="center" nowrap><input name="Button" type="button" class="btn" onClick="MM_goToURL('parent','update.php?ID=<?php echo $_GET['ID']; ?>');return document.MM_returnValue" value="Cancel">                <input type="submit" class="btn" value="Insert record"></td>             </tr>           </table>           <input type="hidden" name="File_FAQ_ID" value="<? echo $_GET['ID']; ?>">           <input type="hidden" name="MM_insert" value="form1">         </form> [/code]
  20. Why dont you use taiths function and add a substr to it to wack off the leading charaters you dont want?
  21. This is my code: [code] if($HTTP_POST_FILES['File_Name']['size'] > 0 && !file_exists("../owner/files/".$HTTP_POST_FILES['File_Name']['name']))   { $FileIn  = $HTTP_POST_FILES['File_Name']['tmp_name']; $FileOut = "../owner/files/".$HTTP_POST_FILES['File_Name']['name']; move_uploaded_file($FileIn, $FileOut); if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {   $insertSQL = sprintf("INSERT INTO faqfile (File_FAQ_ID, File_Name) VALUES (%s, %s)",                       GetSQLValueString($_POST['File_FAQ_ID'], "int"),                       GetSQLValueString($HTTP_POST_FILES['File_Name']['name'], "text"));   mysql_select_db($database_database, $database);   $Result1 = mysql_query($insertSQL, $database) or die(mysql_error()); }   $insertGoTo = "update.php";   if (isset($_SERVER['QUERY_STRING'])) {     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";     $insertGoTo .= $_SERVER['QUERY_STRING'];   }   header(sprintf("Location: %s", $insertGoTo)); } [/code] I keep getting an error that 'File_name' is an undefined index. I have played with file uploads before but not like this. Anyone have an idea?
×
×
  • 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.