Jump to content

mikr

Members
  • Posts

    32
  • Joined

  • Last visited

Everything posted by mikr

  1. If you've got a mysql db, you can have a datetimestamp field in a user table. Every time a page is refreshed, the user refreshes their row in the mysql db. Then, they do a select on that table, looking for all the folks who have refreshed in the last 5 to 30 minutes and count them as who's online. It won't be 100% correct, but it will be roughly correct.
  2. What gamerzfuse means, is, below... function SqlWhere() { // Where Type return (!empty($_GET['type'])) ? "type = '". mysql_real_escape_string($_GET['type']) . "'" : ""; //return (!empty($_GET['type'])) ? "type = '". mysql_real_escape_string($_GET['type']) . "' : ""; } Look closely, you weren't closing out your final single quote after the mysql_real_escape_string(). I've left yours in as commented out so you can see what you missed. Hope that helps.
  3. Try having two loops. First, you check to see if any files succeeded. If they did, decide you don't care about whether any didn't. Then, second loop only if no files succeeded, then try and determine why they didn't. Only one downside, if some files succeed and others fail, you won't have any response. $error = ($_FILES["fileatt"]["error"]); $errorcode = true; for ($i=0; $i<count($error); $i++) { if ($error[$i] == UPLOAD_ERR_OK) { $errorcode = false; } } if ($errorcode ==false) { $fileatt_name = $_FILES['fileatt']['name']; $attachments1 = stripslashes($fileatt_name[0]); $attachments2 = stripslashes($fileatt_name[1]); $attachments3 = stripslashes($fileatt_name[2]); $attachments4 = stripslashes($fileatt_name[3]); } else { for ($i=0; $i<count($error); $i++) { if ($error[$i] == 4) { $action="reply"; $sideaction=""; $error ="You did not upload any file attachment do you still wish to proceed?"; } if ($error[$i] == 2) { $action="reply"; $sideaction="addattachments"; $error ="An error occured, you can only upload files with a maximum filesize of 200KB please try again"; } }
  4. Where you have: $error = ($_FILES["fileatt"]["error"]); for ($i=0; $i<count($error); $i++) { You may want rather, something like: $error = ($_FILES["fileatt"]["error"]); $errorcode = true; for ($i=0; $i<count($error); $i++) { if ($error[$i] == UPLOAD_ERR_OK) { $errorcode = false; } ... What may help is to look at the results of a print_r($_FILES); . You'll see that anywhere you haven't uploaded a file in the four fields, the error code will be set to 4. What you desire (with regard to error code 4), I believe, is that if any one field is UPLOAD_ERR_OK, ignore the fact that some return error code 4. That's what my code above attempts to handle. But, in addition ($_FILES["fileatt"]["error"] == 0) shouldn't work. It's an array, not a numeric variable.
  5. Are you sure? The code you posted has semicolons at the end of the if lines, which means any code within the brackets ({}) will be executed anyways. So, that code will always result in the $error message resulting in "An error occurred, you can only upload files..." Now, I am at a loss if that is just a mistake in inputting to the website here... Hope that helps.
  6. Also, in response to: In your foreach loop, $error is returning an element from the array: $_FILES["fileatt"]["error"] (not the array itself), so if you want the first error, then you will want to check $_FILES["fileatt"]["error"][0]. Or, you could just write $error = $_FILES["fileatt"]["error"];, and then check $error[0].
  7. This may not solve your problem, but it might help move you forward. You are executing your first if statement for every file you attempt to upload. So, if one file out of all fails, your code will sort of act as though they all failed...
×
×
  • 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.