Jump to content

tpl41803

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tpl41803's Achievements

Member

Member (2/5)

0

Reputation

  1. as always thanks for the quick response this does help me optimize the code a little but doesn't solve my problem entirely if i change my isset statement to reflect what you've posted i will be able to get the error page, but it will prevent me from viewing any of the other pages on my site (about 10 static pages -- index, cover, contents, etc...) As far as I can see the problem is that when a bad link comes across (/whatever.php) it forwards it directly to the home page instead of ?p=error&err=404, which is what I want it to do and I can't figure out why it's not posting this properly.
  2. Hey all I built a site a while back with custom error pages that used one php file (error.php) which contained a list of php error messages, the .htaccess file redirected all errors to this file and passed the error through the url in a variable that my error page would request. It worked perfectly. Now, I've created the same thing, but I am using a much more complex (for me) site and the errors arn't working correctly. Here's the gist of my error.php: <?php $error = $_REQUEST['err']; if ($error == 404) { $errorText = 'Document not found. Please check the URL and try again.'; } elseif ($error == 206) { $errorText = 'Partial content.'; } elseif ($error == 301) { $errorText = 'Document moved permanently.'; } elseif ($error == 302) { $errorText = 'Document found in another location.'; } elseif ($error == 400) { $errorText = 'Bad request'; } elseif ($error == 401) { $errorText = 'Authorization required to access the requested area.'; } elseif ($error == 403) { $errorText = 'Access forbidden.'; } elseif ($error == 408) { $errorText = 'Request timed out. Please try again.'; } elseif ($error == 500) { $errorText = 'Internal server error'; } elseif ($error == 501) { $errorText = 'Request type not supported'; } else { $errorText = 'An unknown error has occurred.<br /><br />If you reached this site via a bookmark, please note that the addresses of all pieces on this site changed in July 2010 and bookmarks must be updated to reflect our new format. We apologize for the inconvenience.'; } ?> <div id="content"> <h2>Error <?php echo $error; ?></h2> <br /><br /><br /> <p><?php echo $errorText; ?></p> </div><!-- #content --> The relevant portion of the .htaccess file: Options -Indexes ErrorDocument 206 /?p=error&err=206 ErrorDocument 301 /?p=error&err=301 ErrorDocument 302 /?p=error&err=302 ErrorDocument 400 /?p=error&err=400 ErrorDocument 401 /?p=error&err=401 ErrorDocument 403 /?p=error&err=403 ErrorDocument 404 /?p=error&err=404 ErrorDocument 408 /?p=error&err=408 ErrorDocument 500 /?p=error&err=500 ErrorDocument 501 /?p=error&err=501 Now, my index doc is a list of includes depending on which page is requested. So I have a piece of code like this at the beginning of the doc to get this information: if (isset($_GET['p'])) { $p = $_GET['p']; } else { $p = index; } Finally I call the actual pages through includes and etc: if ($p == index) { require "includes/menu.php"; require_once "pages/index.php"; } elseif ($p == error) { require "includes/menu.php"; require_once "pages/errors.php"; } I don't know if this is a tremendously confusing construction or not, it makes perfect sense to me. I am not a PHP pro (I always feel I need to explain this here). I've read books and gotten help here and taught myself through trial and error. I think my issue is in the isset line and the .htaccess not actually posting the information in the url. If I remove the isset I can get the errors to display, but only an "unknown error," I can never get a 404 to appear as intended. Any ideas what the hell I'm doing wrong / should be doing greatly appreciated thanks again
  3. ah that's exactly what i needed, thanks so much :-D
  4. seems this is the issue, i have broken my script into 2 separate pages, each uploads 20 files at a time, this is not EXACTLY what I was looking for, but it will do until I can find away to override what seems to be a 20 file maximum I've looked through the php.ini settings to see if there is a way to change it but it seems like there isn;t thanks for all your help :-D
  5. that's more or less what I am encountering but I am not receiving the error i guess that means that you can only upload 20 files at a time?
  6. well this is interesting, when i print_r($_FILES) i get an array that counts 0-19. It should be counting 0-39.
  7. I have been playing with the script a little and adding some checks into the code and this new version produces the exact same problem, example: if (!empty($_FILES['ufile']['tmp_name'][0])) { if (!copy($_FILES['ufile']['tmp_name'][0], $path0)) { echo "failed to save '.$path1.'"; } echo "'.$path0.' was saved <br /><br />"; } else { echo "'.$path0.' was empty <br /><br />"; } Now, when I upload the first 20 files, i receive "XXXX was saved" and 21-40 returns "XXXX was empty" DOES php only allow the userfile array only count to 20? I'm not sure if this is really the issue, because if i only upload the 21st file, for example, the script still returns "XXXX was empty" for number 21. not sure :-/
  8. yes i do get error messages when i make syntax errors and things so i know error messages are turned on
  9. added but the result is the same and i don't get any errors reported :-/
  10. Hey all I have an issue with a really bare file uploading script which is supposed to upload up to 40 files at the same time, rename them, and save them to a predetermined directory. My code on a page called PHOTOS looks like this (shortened because it's the same thing repeated for each input): <form enctype="multipart/form-data" action="upload.php" method="POST"> <input type="hidden" name="destination" value="$row['folder']" /> 1. <input name="ufile[]" type="file" id="ufile[]" /><br /> 2. <input name="ufile[]" type="file" id="ufile[]" /><br /> 3. <input name="ufile[]" type="file" id="ufile[]" /><br /> 4. <input name="ufile[]" type="file" id="ufile[]" /><br /> etc... and my php action, "upload.php" looks like this: $destination = $_POST['destination']; $path1= "../sales/inventory/$destination/". "1.jpg"; $path2= "../sales/inventory/$destination/". "2.jpg"; $path3= "../sales/inventory/$destination/". "3.jpg"; $path4= "../sales/inventory/$destination/". "4.jpg"; etc.... if (!empty($_FILES['ufile']['tmp_name'][0])) { copy($_FILES['ufile']['tmp_name'][0], $path1); } if (!empty($_FILES['ufile']['tmp_name'][1])) { copy($_FILES['ufile']['tmp_name'][1], $path2); } if (!empty($_FILES['ufile']['tmp_name'][2])) { copy($_FILES['ufile']['tmp_name'][2], $path3); } if (!empty($_FILES['ufile']['tmp_name'][3])) { copy($_FILES['ufile']['tmp_name'][3], $path4); } etc... I'm sure there are prettier ways of doing this, but it works fine until I upload a 21st files. The script for some reason will only save the first 20 files to the destination directory. I have changed the max file upload size to reflect the amount of bytes I am passing through this script (which is rarely more than 4.5mb). Any ideas why this might be happening? Thanks a lot, always appreciate the help I get when i come here!
  11. i think i have most of my issue figured out, thanks so much for your help i'm sure ill be back with a problem sooner or later -- it's all in practice i suppose thanks again
  12. I don't believe so-- the only issue I can really see is that I am using *'s for nearly all my queries, even if I am only looking for one row. is FROM $table not necessary? I was under the impression that that was necessary on each query or else the script won't know what's going on.
  13. I'm not sure I completely follow you. I follow the * part and I'm going to rewrite the majority of my queries. There are a great many instances where I am using a * and actually only looking for one row of info. So there's some freed memory right there. I'm not sure I'm following the rest of your reply though. By "not necessary to query the location" do you mean the FROM $table isn't necessary? And I have looked into joins in the past but never successfully wrote a join that worked. I think the concept of joins as a whole just eludes me.
  14. thanks for the quick response i've gone through my pages and removed a few extra connections that I didn't realize were unnecessary and although you say it's not entirely necessary I added a mysql_close() at the end of the connections that I am using. I'm not sure what you mean by rewriting the queries so that more of the data processing can be done on mysql's side though. My normal query will look something like this: $result = mysql_query("SELECT * FROM $table $where"); if (!$result) { die("Query to show fields from table failed"); } I'd appreciate it if someone could provide me with a quick example of how to rewrite this to save memory Thanks again!
  15. Hi all I hope I'm posting this in the right place -- I've been looking around on these forms and others and I can't seem to find the answer to my question. I have no real training in php / mysql / etc... Everything I know I have learned through online guides and these forms SO--what, generally, are some good practices for saving memory. I have put together a site that relies heavily on mysql queries -- I may have 10-15 on a single page. I am becoming increasingly worried about the amount of memory and connections I have opened and I am not entirely sure how this works. For example, if I run a query, is it absolutely necessary for me to free the result at the conclusion of the script? I am somewhat under the impression that once the script is executed the result is automatically freed and the connection is closed, but then I am not entirely certain of this. Today I had an issue with my site where every page was loading a "the connection has been reset" error -- I encountered this error when attempting to access the filemanager also. Is this because I have not been freeing my results and closing my connections? Any advice / help greatly appreciated Thnanks
×
×
  • 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.