Jump to content

haku

Staff Alumni
  • Posts

    6,172
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by haku

  1. What are you asking? You've showed us a code, but didn't tell us what the problem is or what issues you are facing.
  2. It can be done both through server storage, or through database management. I use a managed file system (such as CPD is describing) on my web systems. When users upload files, references to them are stored in the database containing the actual file name (which may be different than the originally uploaded file name since I rename files if a file with the same name already exists on the server), the file path, and the file size. I also have another table that stores usage of the file, so that each time it is used, a new reference is created, so that I know when to whether or not to delete the actual file when a reference to it is deleted. This managed file system is overkill for some sites however, and a simple check of actual file sizes in an existing directory will suffice. Both systems have their place, so there is no 'right' or 'wrong' answer, there are just different ways of doing it. In this case, since file sizes are to be calculated per user, I would go with the managed file system, so that the DB can be queried at any given time for a quick response as to the amount of storage that a given user is using.
  3. You are also adding overhead to each page load by checking for and logging out users on every page load. If you really want to do this, you are best off creating a script to do this, and having it executed using cron runs in the background.
  4. Generally it's a problem in your code.
  5. Hah, I always get them mixed up. I have troubles with English sometimes. Brackets, parenthesis, braces. They screw me up.
  6. Close, but that's going to fail when it's January. Unfortunately I have to run for my last train, so I can't add anything now. If someone doesn't by tomorrow, I'll give it a shot.
  7. Here is how people generally format code: <?php $conto=count($array_dir); echo"<table border=\"1\">"; for($b=0;$b<$conto;$b++){ echo"<tr><td width=\"300\" height=\"50\"><img src=\"folder.png\"><a href=$array_dir[$b]>".$array_dir[$b]."</a><br>"; echo"<form action='' name='deleteform".$b."' method='GET'>"; echo"<input type='submit' name='deletebut".$b."' value='Delete'>"; echo"</form></td><td>"; if(file_exists($array_dir[$b])) { if(isset($_GET['deletebut'.$b])) { if($_GET['deletebut'.$b]==$array_dir[$b]) { if(rmdir($array_dir[$b])) { echo $array_dir[$b]." was removed"; } else { echo"Failed to remove directory ".$array_dir[$b]; } } } ?> With this, you can see at a glance that you are missing some parenthesis. With the formatting you used, it was difficult to see that. As a side note, I actually format differently: <?php $conto=count($array_dir); echo"<table border=\"1\">"; for($b=0;$b<$conto;$b++) { echo"<tr><td width=\"300\" height=\"50\"><img src=\"folder.png\"><a href=$array_dir[$b]>".$array_dir[$b]."</a><br>"; echo"<form action='' name='deleteform".$b."' method='GET'>"; echo"<input type='submit' name='deletebut".$b."' value='Delete'>"; echo"</form></td><td>"; if(file_exists($array_dir[$b])) { if(isset($_GET['deletebut'.$b])) { if($_GET['deletebut'.$b]==$array_dir[$b]) { if(rmdir($array_dir[$b])) { echo $array_dir[$b]." was removed"; } else { echo"Failed to remove directory ".$array_dir[$b]; } } } ?> As you can see, it's still quite clear that there are two parenthesis missing. The actual formatting you use is mostly arbitrary (though when you are coding a project with other people, it's generally a good idea to match styles for consistency). The key point is that you format your code in an easy to read manner. It will not only save you hours and hours of headaches over time, it will also make it easier for people to help you, since they won't have to try to figure out what is going on in messy code. And when it's easier for people to help you, they will be more likely to do so. Good luck!
  8. Your onkeyup function is being called here: <input type="text" id="searchBar" onkeyup="searchoption()" list="sop" /> You are using the 'onkeyup' attribute of the <input> element. When the key comes up, you are calling the function searchoption(). In this function, you will need to do a test to see which key was pressed. If it's the up or down area, you will want to highlight the previous/next element, or if it's anything else you will want to hide the popup.
  9. Step one to writing good code is proper indentation. You should start there. Also, please post your code using code tags. You can do this using the <> button in the editor.
  10. You can only have one auto increment column in a table, so you'll need to manually increment any other columns.
  11. You are already printing the category name. Since you seem to want something else, give us an example of the output you are trying to achieve.
  12. ereg functions were deprecated in php 5.2 or 5.3. Only PCRE (preg) regex are valid. You will need to convert your ereg functions to preg functions.
  13. I believe Barand has posted the best non-regex solution in his first response. If a regex solution is preferred, then there have been two posts here that do it in a single regex.
  14. Once again this editor screws things up. Here's the link for anyone else who wants it: http://www.devarticles.com/c/a/Javascript/Regular-exp<b></b>ressions-in-Javascript/6/ Edit: Can't even fix it. Google it if you want the link.
  15. Apologies, wrong function. mysql_data_seek() is the function you want, not reset(). reset() is for arrays, as the error you are seeing is informing you.
  16. You need to reset the internal pointer to the first element before you can use $result again: <tr><td>account to transfer</td><td><select name="accountname2"> <?php reset($result); while($row=mysql_fetch_assoc($result))
  17. If a hacker has compromised your database, then your salts become pretty irrelevant, as they can get access to your file system by including PHP code in a database column, executing it, and thereby gaining access to the file system which will then give them your salt logic.
  18. Just because it's widely used doesn't make it any less valid of suggestion for a salt. Or if you feel it is, then you'll have to elaborate as to why.
  19. To elaborate: $something = 'hello'; $single_quote_string = 'Look at this: $something'; $double_quote_string = "Look at this: $something"; echo $single_quote_string . '<br />' . $double_quote_string; The output will be as follows: Look at this: $something Look at this: hello
  20. Exactly. Your best bet is to save it to the temporary folder on your server, so it will be cleared out periodically. Then you will need to save the location of that file somewhere that the user cannot see (for security reasons), so a SESSION variable is probably best. Then you can reference this on the second (or third or whatever) submission attempt when there are no errors.
  21. I usually salt with the timestamp of the user registration.
  22. Xaotique already replied for me, but to elaborate:
  23. We help here for free. If it's urgent, hire someone to do it for you. Otherwise you will have accept the help that you get. Telling us it's urgent comes across as rude, as it essentially is telling us to hurry up the work we are doing for free.
  24. A freebee for you. This will test if the first digit is one, and the rest of the characters after the one are also numeric. If the first digit is not 1, or any of the rest of the characters are not numeric, then it will return false. if(f.match(/^1\d+$/))
×
×
  • 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.