Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Ok, if this was my program, I would debug it by putting print statements inside each of the "if" conditions that I suspected. Then you can see if they are being executed. If they are not executed, then either the condition is not being matched, or the condition is not even being checked (due to the program logic). After that you will know exactly which code is executed. Next is either fixing the code that is executed, or making it so the code you want is executed (after finding out it wasn't when it should be). For that, I would use var_dump($song) to see what's inside the $song, and ask myself why it is not matching the condition? It may be something subtle like the "blank" values having some invisible character in them, and therefore not matching the empty() condition.
  2. You need to add/delete columns, not rows .. is that's why it's not making sense? Columns describe the format of the data, rows are actual pieces of data.
  3. If you just want to copy the data, you can use CREATE TABLE foo SELECT * FROM bar If you want an exact copy including indexes and so on, I can't help you there.
  4. 30-40 seconds for 1000 files seems too slow .. can you give more information about the system this is running on? Which OS? and is there any other load? You might also want to try glob() According to the user comments though, opendir() is usually faster than glob()
  5. So even the first one, the Equalizer check, is not working? Ok I understand the problem. I notice that you mysql_real_escape_string() your variables before you call check_row() .. could that be part of the problem? Even if $song is altered by check_row(), those changes will not be reflected in your $song_* variables
  6. The function finishes after one of the conditions is met, because of the return. Could that be causing the problem? Two more things - First, your formatting makes it very difficult to read the logic of your code! Second, you can write like this: if (something) { blah } elseif (somethingelse) { blah } elseif (somethingelse) { blah } I think that style is much easier to read than the continual nesting you have used in your code.
  7. Can you slow down a bit with the explanation? I have no idea what you're talking about If you want, include a schema of your tables and some sample code. What we will definitely need is your query which is supposed to list users who have completed the previous stage but is not behaving as you expect.
  8. Are you familiar with arrays and sorting? The simplest solution here is to put the values into an array and sort the array. For example $D[1] = 444; # ... $D[10] = 24; rsort($D); foreach ($D as $num) { print "$num\n"; } Manual for rsort()
  9. Here's a suggestion for how to represent your files so they're easier to deal with: //Step 1 - make the file into a single array, so it can be dealt with as one unit $file_data = array( 'filename' => "getamac-misprint.avi", // Note change from $file to $filename 'title' => "Mac Ad: Misprint", 'thumb' => "getamac-misprint_tn.png", 'thumb_width' => "200", 'thumb_height' => "150", 'size' => filesize("files/video/{$file_data['filename']}"), // <-- Note change here ); // Step 2 - Make a reusable function which can display ANY file with a single call function display_file($file_data) { extract($file_data); // Convert array variables to full variables print "<tr><td>\n"; print "<a href='humor_video_play.php?file=$filename&title=$title'>\n<img border='0' src='files/video/thumbs/$thumb' width='$thumb_width' height='$thumb_height' alt=' '></a></td>\n"; print "<td><a href='humor_video_play.php?file=$filename&title=$title'>$title</a><br>\n"; print "<a href='files/video/$filename'>download file</a> | file size: "; include("text_files/filesize.php"); print "$size\n"; print "</td></tr>\n"; } // Step 3 - demonstrate re-usable function display_file($file_data); // Step 4 - Add this file's data to an array of file datas $all_files[] = $file_data; // Example - Iterate over full array (assuming you added many more files), displaying each file foreach ($all_files as $file_data) { display_file($file_data); } The basic idea is to get all the file data as one unit so you can deal with it easily, and also to stop repeating your display code for each file (since it's identical each time).
  10. Or if you don't mind using antiquated C style functions: $a = 197.333333; $minutes = floor($a/60); printf("%d minutes\n", $minutes); printf("%.0f seconds\n", $a - ($minutes * 60)); printf's rounding will go to the closest number. You can use sprintf() if you want to store the result in a variable instead.
  11. You could also say that all random numbers have a pattern, if you allow arbitrarily complex patterns. For example, the pattern for 364,255,927,584 could be "364,255,927,584". So what counts as a pattern needs to be defined. For example, you may be looking for patterns where the numbers increase according to some simple rule (as in cooldude's example).
  12. Your program design makes this very difficult. But I can think of a few ways to do it. One way is to set a variable $num_files = 0 at the top of your include. After displaying each new file, you increment $num_files by 1. And around each file, you check if ($num_files >= $offset && $num_files < $offset + $limit) { # display file } If you're willing to do some rewriting of your program, you can put all the html for each file in an array instead of printing them immediately. Then you can just use $display_array = array_slice($full_array, $offset, $limit); foreach ($display_array as $html_output) { print $html_output; }
  13. pfsockopen() does not operate with sessions. Resources cannot be place in sessions in any case. It's not clear from the manual what the correct usage is, but from the comments it appears to be that you make the same call that you made the first time, and you will receive the persistent socket.
  14. Yes you can use any name you want. $result->free() frees every row in the result, so it can only be used when you are finished completely with that result. If you want to reset the row pointer, there's probably a method like $result->data_seek()
  15. Thanks, I can see a problem already. You are fetching one row before the for loop, which will explain why the first item is skipped. You can solve that either by resetting the data pointer or by explicitly requesting your rows by number. I'm not familiar with the OO interface you are using, so I can't give specifics on how to do that. Also I just want to check, are you intending to reuse $result for both the first query and second query?
  16. Can you show us the code between your sql query and this for loop?
  17. Perhaps openssl was pulling in an older mysql library? I don't see why openssl would require mysql, but maybe it affects the library path somehow.
  18. I think that's a very natural data structure. I use similar structures all the time in my own code. While it's not memory efficient, it's very easy to understand and use.
  19. Ok that structure makes sense. What makes you think it might not be ok to pass it to another programmer?
  20. Are you 100% sure that that is the code generating the error? Does PHP_SELF occur anywhere in any of your other code?
  21. Can you show a bit of sample data? One line from the header data and body data should be enough. I don't yet understand the data structure.
  22. Are there any other versions of the mysql libraries installed on the system? Someone had a similar problem here
  23. The "right" way to do it is to store one row for each forum that is moderated. This can be in a separate table indexed by user id, instead of duplicating entire rows from your users table. But you an also store it as a text string like "1,2", and use implode() to store the data and explode() to read it. As long as one person doesn't moderate more than 10 or so forums, this method will be quite efficient.
×
×
  • 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.