Jump to content

Kieran Menor

Members
  • Posts

    179
  • Joined

  • Last visited

Everything posted by Kieran Menor

  1. Or depending on what exactly you mean, call_user_func_array might be what you are looking for.
  2. Maybe output buffering is enabled? Try calling ob_flush() before flush()
  3. And this won't suffice? $data = array(1=>"hello", 2=>"welcome"); function doSomething($array) { // $array[1] = hello , $array[2] = welcome ... etc. } doSomething($data)
  4. Well, you could just crop the MD5 hash to the desired length. Example: $forty_bits = substr($md5_hash, 0, 10); // 40 bits (10 hex digits of 4 bits each) is enough for a 10 digit decimal number $decimal = base_convert($forty_bits, 16, 10); // Convert from hexadecimal (base 16) to decimal $ten_digits = substr($decimal, 0, 10); $padded_result = str_pad($ten_digits, 10, '0', STR_PAD_LEFT); // Pad the resulting number to 10 digits, just in case
  5. Drop-down lists are like any other form elements. Alike so: <form method="POST" action="posthandler.php"> <select name="gmt"><option value="...">...</option></select> <input type="submit" /> </form> and in posthandler.php: <?php echo $_POST['gmt']; ?> It seems that in your case, all you need to do is to move the <select> element inside your <form>, and possibly add action="POST" to the <form> also.
  6. This is probably more of a HTML issue. Try wrapping the output in <pre></pre>.
  7. Or even better, you should do a check to see if your divisor is zero so you can handle the situation correctly.
  8. Depending on the encoding, most of the time, you won't really have to worry when working with such files. Try doing it like you normally would with any other file.
  9. I don't, sorry, but feel free to ask if you get stuck.
  10. That should be perfectly possible, yes.
  11. Could we see the code that processes the form? Textareas are supposed to show linebreaks correctly, so what you are describing sounds rather weird. Regarding the £ sign, it seems to be a character encoding problem. What encoding are you using for your page?
  12. Well put the function at the start of your script. Then you can call copy_r('foldertocopy', 'destination') at any time.
  13. This function looks like a decent candidate.
  14. Ah. Well in that case, you will need something slightly more advanced. Try looking in the user comments on the copy page. I'm sure you can find a snippet that will help you.
  15. What exactly do you need to copy?
  16. A simple loop would be fine for the task. Something like: foreach(glob('folder/*.*') as $file) { copy($file, 'destination/'.basename($file)); }
  17. So, what. You want people to be able to upload videos to your site, which in turn will upload them to YouTube?
  18. It seems more likely that it's the exec() causing the problem, to be honest. Why would you need to copy files that way anyway? PHP has a copy() function.
  19. I'm not entirely sure what you are trying to do. Could you try to rephrase the question?
  20. What error messages do you get? Did you actually enable root logins for your database?
  21. You cannot open a PHP script directly in a web browser. It has to pass through a web server. The reason is that PHP is a server-side scripting language, meaning it is parsed by the server before the result is sent to the browser. As such, you will not be able to view a PHP script located anywhere on your hard disk correctly. If you are linking from a HTML file on your hard disk to a PHP script on a local web server, make sure that the link points to http://localhost/myscript.php and not C:\whatever\myscript.php.
  22. I imagine that you don't need all the irrelevant data fields. I didn't design this table myself, and now that I look at it, "birthday" is actually a date field. So, okay, the table looks something like this: CREATE TABLE `members` ( `id` int(12) NOT NULL AUTO_INCREMENT, `zipcode` varchar(55) NOT NULL DEFAULT '', `birthday` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`id`) ) ENGINE=MyISAM ; "zipcode" is always a 4 digit number, so you can definitely use another data type to increase efficiency. Also, I see that the table currently has no indices (other than PRIMARY).
  23. Awesome, it seems to work. Thanks a lot. Although, it takes about a minute to execute. This doesn't matter much now as I only need to pull out the data every once in a while. The table only has about 6000 rows now, though, so I imagine it would get much worse later. Any ideas for optimization would be much appreciated.
  24. Not really. The topic title is "Filtering array". In his post he mentions that he would like get all the entries that have a certain "Cat" value. My function does exactly that.
  25. I don't think it has any relevance, but here it is: SELECT `zipcode` , ( YEAR( NOW( ) ) - CAST( SUBSTRING( `birthday` , 1, 4 ) AS SIGNED ) ) AS `age` , COUNT( * ) AS `count` FROM `p_member` GROUP BY `zipcode` , `age` ORDER BY `zipcode` , `age` It returns a result similar to the example in my first post, but as mentioned (and expected), it doesn't list rows where the count is 0. As I said, what I want is a list of all ages for each postal code, and the amount of rows that match, even if it is 0.
×
×
  • 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.