Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. You'll need the HAVING clause: SELECT ArtistID,count(*) as count FROM yourtable WHERE Rating <= 3 AND UserID=1 GROUP BY ArtistID HAVING count >=3
  2. At the heart of all of your questions is the problem of database stucture. You should not be storing a comma delimited field in one of your columns. You should have a separate table listing all invites to networks and all networks that a person belongs to. I suggest you read up on database normalization. This topic here might get started.
  3. It doesn't really matter where the user input comes from, it's what is done with it that is important. It is entirely possible to attack a site's database through GET variables if the site has been poorly made.
  4. Indeed. It will match anything of the form *.* --basically all files, no directories.
  5. Quite possibly the best solution -- can be done under windows too.
  6. Indeed. You can only delete a directory once it is empty; you will have to remove all the files first. If there are no subdirectories in the folder you wish to delete, you could use: <?php $dir = 'test2/'; foreach(glob($dir.'*.*') as $v){ unlink($v); } rmdir($dir); ?> Otherwise, you'll have to write a recursive function (examples of which can be found on the user contributed notes in the manual here or here)
  7. The second condtion will only be evaluated if the first returns false. What would be the point of continuing anyway? As for your POST question, I'm still not entirely sure what your mean. Do you mean that instead of doing $var = $_POST['var']; echo $var; You would just like to be able to do: echo $var; If so, then this is the behaviour of PHP with the register_globals setting turned on. However, it is a security issue, and should be turned off. You could take all the variables from the POST array and create variables for each with the extract function. But i wouldn't recommend it.
  8. Yes, to use the COM to create a word document, you do need to have Word installed. I believe you can work around this either by creating RTF documents which word can open anyway, or creating HTML pages but setting the content type to a word document. If you google, you should find examples.
  9. 1.) Im not entirely sure what you mean. 2.) Yes you could encrypt data with md5 or similar, however -- you can't decrypt md5 so that would be a bad choice. You could look into the mcrypt extension (see: here) 3.) No. If the if statement evaluates to true, then the else if will not be tested.
  10. Well, the first step is to create the form in HTML. The next step is to gather that information and put it into a text file. You'll need the fopen[/ur] and fwrite functions for that. You may also wish to perform some validation on the data prior to it being written to the text file. To require the file to be downloaded, you'll need to send certain headers and use the readfile function. This process is described here. p.s. Welcome to the forums.
  11. Question 10: The question says "How would you check to see if a value is an integer?" - it does not say how do you check if a variable is an integer. I think there's a difference. And yes, i'm aware i was splitting hairs with question 21.
  12. Question 10 is misleading - is_int() checks a variable's type. Question 11 is misleading, you could leave a loop with exit, you just wouldn't return to the rest of the script. Question 21 is wrong. The answer is true. Firstly you can leave the semi-colon off the last line of your php code. It would also be debatable about what you mean by statement -- you do not need a semi-colon after an if statement.
  13. Of course, yes. Not entirely sure why I didn't realise. Can't think of an easy way off the top of my head, but ill have a think.
  14. What was the point of your table tie? It'd be much easier to add a field called category_id to your posts table...
  15. Looks like you need to find the caps-lock key too.
  16. 2.) Yes - to exclude all directories, add !is_dir($files[$ctr]) to your if statement. 3.) The explode function separates the string by a full stop, and it is broken into two pieces (forced with the second parameter to allow for extensions such as .inc.php) The list function allows you to create variables from an array. Therfore, $file is the first part of the string --that is, the bit before the first full stop -- and is infact completely useless to us. We're only interested in the part after the full stop, which we call $ext. Make sense? Oh, and when you post your code in future, dont forget to use the tags please
  17. Eugh. Use arrays! <?php $dir = '/path/to/root/directory/'; // Path to root directory. $files = scandir($dir, 0); $excluded_files = array('CMS','CSS','FLASH','.htaccess')//etc $excluded_extensions = array('php','inc.php');//etc for( $ctr = 1; $ctr < sizeof( $files ); $ctr++ ) { list($file,$ext) = explode('.',$fils[$ctr],2); if(!in_array($files[$ctr],$excluded_files) && !in_array($ext,$excluded_extensions)){ print "<span>$files[$ctr]</span>\\n"; } } ?> If you didn't want to include any of the directories, you could use the is_dir() function and save yourself some typing.
  18. I'd say you should fix the problem by turning off the register_globals setting if at all possible (though you might experience problems with forms etc if you've been used to writing code with register_globals turned on).
  19. Indeed. Posting some code would be useful. Though it sounds like you could do with escaping your data with mysql_real_escape_string
  20. Indeed - you'd need to do : $customcolor = $_POST['customcolor']; However, im not sure what value you wanted it to take. And it wouldn't remain checked with the code you have presently either - to make a checkbox checked you need to set the attrribute: checked="checked"
  21. Yes of course it is, though you're unlikely to find anything pre-written unless it came with the above gallery script.
  22. Oh mon dieu, use the tags! As for the problem, as far as I can see, you never extract $customcolor from the POST array. Though you might do somewhere. Narrowing down the problem area for us would help us help you.
  23. Or possibly exceeding one of the other relevant resource restrictions (file size, etc). Why not post the errors now?
  24. If you have access to a database, it would be easier to store the file names an captions there, rather than opening an HTML file and inserting a new image tag for each upload. Edit: And even if you dont have access to a database, it would easier to store file names and captions in a flat file, and parse that in your gallery page.
×
×
  • 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.