Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Ah, so you actually meant to say it prints "hello world" when run from the command line too. What's the problem?
  2. You can't use an empty string for an INT AUTO_INCREMENT. Either omit the column entirely or use NULL (or 0) as the value.
  3. Then you're not using absolute links like I posted. What's your code now?
  4. You say you "can't figure out how" so that must mean you don't know how to proceed. Typically you either a] Make the form post back to the same page and find a way to move the logic from the other page into it. - Could move the logic into functions and call those functions - include() might even work b] Make the target page do the error checking and show this page if there's a problem. - Could redirect if you can find a way to pass along what values were entered what what the error messages are. Maybe sessions - include() might even work
  5. What's the code for this script you're running? Exactly how are you running it?
  6. http://cronanpilotcar.byethost33.com/images/gallery/Mustang.jpg Works for me.
  7. Use absolute links. And please try to avoid using .. in URL paths if you can. echo ('');(the leading slash is what makes it absolute)
  8. Just want an algorithm? Define another array, like $table, that tells you what "group" each cell belongs to. It should eventually end up like $tablegroups = array( array( 0, 0, 0, 0, 0, 0), array( 0, 0, 1, 1, 0, 0), array( 0, 0, 0, 0, 0, 0), array( 0, 2, 0, 2, 0, 0), array( 0, 0, 2, 0, 0, 0), array( 0, 0, 0, 2, 0, 4) // * );Loop through all the rows in $table (first dimension) then the columns (second dimension). foreach ($table as $r => $row) { foreach ($row as $c => $column) {Skip over empty cells. Look at the previous column (if present) and the three cells above in the previous row (if present) in $tablegroups, ignoring empty cells. if ($r > 0) { if ($c > 0) { // look at [$r-1][$c-1] } // look at [$r-1][$c] if ($c < 5) { // look at [$r-1][$c + 1] } } if ($c > 0) { // look at [$r][$c - 1] }- Assign this cell to the first group you find. Since you're ignoring empty cells and all four possible cells have been examined previously, every cell you find will be in a group- If there are multiple groups then merge the groups - If there are no cells/groups then create a new group - Update $tablegroups for the current cell Now define merging groups: 1. Pick a winning group 2. For each cell in the other groups, 2a. Move it into the winning group 2b. Update $tablegroups accordingly * If getting groups 1, 2, and 4 is a problem (should be 1, 2, 3) then you can renumber the groups at the end
  9. You wouldn't want to do it with purely PHP as you'd have to decode the MP3. Get the ffmpeg program. That can tell you the exact length and, I have no doubt, extract a portion of it. Then execute it with functions like exec() or even ` backticks.
  10. krsort() sorts based on the keys of the array. $files will just have useless numeric keys. You want rsort. Also your if ($d) won't help anything. All you're doing is checking whether $d has a value. It definitely does. If anything you'd check whether $files has anything, but you can let the foreach do that for you (since you don't do anything else). Unraveling a little bit more, if you're doing a basename() and providing a link to the file, the script will only work for $d=the current directory. If you provide anything else then you'll have to remove the basename for the link to work. Meanwhile glob() doesn't need to know about the ./ path since it'll default to that anyways. Removing that means you don't need basename() at all. And now you're left with <?php // $d = ""; if you really want something // if not the current directory then include the trailing slash, like // $d = "subdirectory/"; // so that the filename pattern you give to glob() remains only the filename $files = glob('Publication_*.pdf'); // $d . 'Publication_*.pdf' rsort($files); foreach ($files as $f) { echo "<a href='{$f}'>{$f}</a><br />"; } ?>
  11. You can't do it simultaneously. Use two loops like you showed.
  12. It's not even a question of practice: you have to put them in there because you don't know what directories to delete until then. By the way, the array_map() I used is functionally equivalent to your foreach loop.
  13. Are you going to tell us what chat thing you're talking about?
  14. Then use the normal form mechanisms without trying to AJAX it.
  15. The only thing I see wrong is how many loops you have. There's only one array to loop over. Use only one loop. And I would love it if people learning a language would try to adapt to the language instead of forcing their own learned habits upon it.
  16. If you can get it into SimpleXML then navigating to the data you want is easy. $dispatch = current($xml->xpath("//State/Center[@ID='INHB']/Dispatch[@ID='BCCCC']")); // assuming there's only one match foreach ($dispatch->Log as $log) { // attributes work like $LogID = (string)$log["ID"]; // elements work like $LogTime = (string)$log->LogTime; }
  17. Randomize the sentences? Get it into an array and shuffle it. That's one of many options.
  18. Doesn't seem to work how? It's not like I can see what you're doing.
  19. "Very large" as in it can't be loaded into memory with, say, SimpleXML? Or lacking that DOMDocument?
  20. Use an array instead of lots of variables. found a mirror = false for each $mirror in your list of mirrors { check response if okay { found a mirror = true show $mirror } } if it did not find a mirror { do something }
  21. If you're not on Windows, strptime.
  22. Is Psycho going to reply? Should I wait? Oh, now he's gone... And your question is... why it says the store could not be deleted? You have to delete the files in the folder before you can delete the folder. If you only have files in the folder then array_map("unlink", glob("store/store_folders/" . $store_name ."/*")); rmdir("store/store_folders/" . $store_name);should get the job done. Otherwise you'll need something a bit more complicated... This also assumes PHP is allowed to delete the files - you didn't manually upload them yourself or something.
  23. Take a look at the code: it uses is_numeric and intval. Even just guessing at what those functions do based on their names, they show $expire is supposed to be a number. If it's used then it gets added to time. That's the current number of seconds since a point in the past, so the number being added to it must also be in seconds. Since those two values get special treatment they have special meanings besides the general case. The code for -1 involves $_SESSION so that special case is to store the verification in the session (which typically only lasts as long as the browser is open). The code for 0 involves creating an expiration point in the future that's 30 years ahead so that special case is to store the validation, for all intents and purposes, indefinitely. Check the manual for what mktime() does. It's not. It is set two different ways in two different places, but it is not set twice. Presumably a default value for $expires. Seems like you're supposed to change it to suit how and when you want the validation to expire. Doesn't matter. You might as well ask why $redirect_url is set before $expires. If you want to allow "remembering" the validation in only one particular way then sure. Like boompa said you need to learn PHP and programming in general. If you keep up your strategy of copy and pasting things you find on the Internet then you're gonna have a bad time.
  24. Be sure to require the login for /client/joe too.
×
×
  • 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.