Jump to content

Vel

Members
  • Posts

    130
  • Joined

  • Last visited

About Vel

  • Birthday 12/26/1984

Profile Information

  • Gender
    Male

Vel's Achievements

Member

Member (2/5)

1

Reputation

  1. Yes, that's exactly what I was after. Thank you very much. Never heard of the pow function before.
  2. OK, in the code above the function goes from 0 up to an unknown number (max of 11). Each loop through it tests the result row[0] for the next bit to see if it is set. So first loop through it is if(($row[0] & 1) == 1) $hours[$j]++; Second loop through it's if(($row[0] & 2) == 2) $hours[$j]++; Third... if(($row[0] & 4) == 4) $hours[$j]++; If you see my OP that number is a variable, $bwt. That is determined by a manually filled in array right now. However what I want is a mathematical function to get that number for me, so I can put in the bit, and get the decimal value for it: i.e. Bit = Decimal 1 = 1 2 = 2 3 = 4 4 = 8 5 = 16 6 = 32 7 = 64 8 = 128 and so on.
  3. So in binary the first bit = 1, the second bit = 2, the third bit = 4, the fourth = 8 and so on. I have manually filled in an array for that. If I specify the bit, is there a function that will give me the decimal value of that bit. I always thought it was 2n, but that does't work.
  4. I'm going through a loop and using an AND check to see if an appropriate flag has been set, and if so increase the appropriate hour by 1. Code is (without all the SQL getting the data): <?php while($row = $result->fetch_row()) { for($j = 0; $j < $bat->length; $j++) { $bwt = $bitwise_array[$j]; if(($row[0] & $bwt) == $bwt) $hours[$j]++; } } Right now bitwise array is just a manually populated array with 1,2,4,8,16 etc... However is there a mathematical function for calculating the proper bit in decimal?
  5. If you include the file anything in that file will be outputted on index.php.
  6. Thanks for the advice guys. I appreciate it.
  7. Sorry, I mistyped it in my haste. I do use isset to check if it exists, and if it does increment it by 1, otherwise set it to 1.
  8. What you need to do is add an extra variable to the form as a hidden variable, call it form_submitted and then check for that variable before including file_upload_script.php. That way you won't get the error message if you haven't submitted the forum. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="da" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> .style1 { text-align: left; } </style> </head> <body> <p>UPLOAD FILE</p> <form enctype="multipart/form-data" method="post" action="file_upload_script.php"> <div class="style1"> Choose file:<br /> <input name="file1" type="file" /><br /> <input type="submit" value="Go" /> <input type="reset" value="Reset" /> <input type="hidden" name="form_submitted" value="1" /> </div> </form> </body> <?php if(isset($_POST['form_submitted'])) include("file_upload_script.php"); ?>
  9. This is more of a question of "is it OK and / or correct" and a point of interest to myself (and hopefully others) than anything else. I have a situation where in a multidimensional array I am counting the number of entries in another part of this array. I have this statement: if($array[$i]['counter']) $array[$i]['counter']++; else $array[$i]['counter'] = 1; It would make sense to me to cut the code down and remove the if statement, and just go with: $array[$i]['counter']++; Completely ignoring the step of checking to see if it's initialised, and if not initialising it. I'm guessing this isn't totally proper, but is it completely incorrect to do this or is it an acceptable way of saving a couple of lines of code?
  10. Someone told me that htaccess doesn't work on Windows. From my own experience that seemed to be true, so I took it as that. PFM pointed out I was wrong, you just posted something sarky. And this is the second time you've done that when I've posted something incorrect. I'm still learning and I know I'll get things wrong, but that's no reason to be like that about it. You'll find people much more receptive to you if you just help them instead of insulting them.
  11. K, if you see one of my posts, please, don't bother responding. What PFM put was helpful. You're just an ass.
  12. .htaccess only work on Linux. If you try to run them on windows you just get a 500 internal server error, or at least that's the result I get ever single time I've ever tried. Or maybe that's just for URL rewite, which is what we use .htaccess for. Why not? All you are trying to do is get the php code on one page to run so that you can debug it. In fact, you only need that problematic portion of the code to run. A .htaccess file has no bearing on the php code after the php code has been invoked. Good point, although it wouldn't be exactly the same as running it where it is right now, it should be similar enough.
  13. Unfortunately our web host forces display_errors off. Not the ideal situation, I know. I've tried forcing them on using a php_ini file to no avail. We are in the process of getting a development server to solve that problem. In the mean time, I can't work on WAMP, or something like that as the website uses .htaccess files. I've solved the problem of the -1 being outputted instead of the +1. I wasn't incrementing the counter when putting the filters into $tmp, so $tmp only had one field, yet the script expected multiple. That still doesn't solve the initial problem, although I now have a work around. I'd like to know why it was throwing a Premature end of script headers error though, if anyone can explain?
  14. OK, a little more information that I think totally screws my approach to this. I saw that using unset($tmp[$out]['opt']) worked, so I thought I would unset that and then check if that was unset instead, so I modified _temp_first to if(isset($tmp[$i]['opt'])) return $i; else ... Same problem, 500 error, Premature end of script headers. So, I can't check for an unset variable in my header. So next I tried to set $tmp[$out] to NULL, same problem. When checking if it exactly equals null I get internal server error, same error in the logs. I then tried setting $tmp[$out]['opt'] == ""; and $tmp[$out]['num'] == -1; and then in _temp_first check for $tmp[$i]['num'] == -1. In theory this should have worked, but for some reason the first option outputted again instead of the second option (no 500 error though, making progress). I just need to debug why the -1 was outputted instead of the +1 now.
  15. Your posting in the wrong section. This is for people who have written code and need specific help solving a bug in that code, or have at least attempted to have a go at writing some code.
×
×
  • 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.