Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Everything posted by akitchin

  1. i couldn't really tell, it was a little erratic.  i had an array of filenames, of which a few started with numbers, others with upper case and others with lower case.  i believe it processed them in the order of number in numeric order, upper case in alpha order, lowercase in alpha order.  i was using sort($array, SORT_STRING). i ended up using natcasesort(), and it fixed the issue.
  2. it would still be nice to see the input's HTML to verify that it isn't a spelling or notation error.
  3. a note about sort:  it doesn't sort the items alphabetically as one would expect, even if you specify comparison as strings.  in the case that you want array items sorted as a human would alphabetically sort them, use natsort() or natcasesort() (the latter being a case-insensitive version of the natural sort). and yes, i know this post has strayed off-topic, but i figured i'd point it out while sort() was being mentioned.
  4. it sounds to me like all you need is a multiple-field ordering clause: [code]ORDER BY restaurant_city ASC, restaurant_name ASC[/code] this will sort by city first, then among each city, by restaurant name. (agreed about the importance of leaving a key be)
  5. you have the patience of a saint, barand.
  6. i think you'd be well off looking into AJAX for this, since it's fairly simple to implement if you have the patience to understand the basis behind AJAX.  furthermore, after getting a basic grounding in AJAX, an entire world of options opens up. try following the introductory tutorial at [url=http://www.ajaxfreaks.com]www.ajaxfreaks.com[/url] (pardon the blatant in-promotion), and then have a look on google for "AJAX".  apple.com in particular has a decent run-down of it.  it helps to know a little bit about javascript. it's simple - run the form's POST request to your file upload script, and while the server is processing it, display an "uploading.." message or image into a previously hidden DIV.  get a good grasp on the basics and you'll find it's fairly easy from there.
  7. well if you want to get everyone that has been online in the last 5 minutes, you can use entirely MySQL functions: [code]SELECT username FROM online_users WHERE time_online > DATE_SUB(NOW(), INTERVAL 5 MINUTE)[/code] this will grab the username of anyone whose status was updated in the last 5 minutes (by checking if their hypothetical time_online field is more recent [or greater] than 5 minutes ago). don't forget to change the query to suit however you're storing the users and their time.
  8. you can just use a UNIX timestamp.  update the db, then run: [code]<?php $_SESSION['status_updated'] = time(); ?>[/code] then when you want to check whether five minutes has passed, check the session's time against the current time like so: [code]<?php $time_difference = time() - $_SESSION['status_updated']; if ($time_difference > 5*60) {   update again, reset $_SESSION['status_updated'] to current time } ?>[/code] this is in the case that you want to use 5 minutes.  a UNIX timestamp is measured in seconds, so we compare the time difference to whatever interval we want in seconds.
  9. well without knowing exactly how you want it formatted, you could toss all the server info into an array with which you can echo the data anywhere on the page: [code]<?php //////////////////////////////////////////////////////////// // Insert this code in your page to get the server status // //////////////////////////////////////////////////////////// // retrieve information from Ryzom's website $server_data = file('http://atys.ryzom.com/serverstatus/status.php'); $status_array = array(); foreach ($server_data AS $data) {   // explode the current server's info into useable chunks   $pieces = explode('|', $data);   // set the proper status   switch ($pieces[1])   {     case 1: $status = 'OPEN'; break;     case 2: $status = 'LOCKED'; break;     default: $status = 'CLOSED'; break;   }   // plug the info into an easy-to-handle array for later use   $status_array["{$pieces[0]}"] = $status; } ?>[/code] the info will then be in the format $status_array[server] = status, so you can use a foreach on it: not too clear on how you want it formatted, but at any rate, there's my input.
  10. looks to me like you're using single quotes around the table name when you shouldn't be.  either use no quotes at all or use backticks (`).
  11. if you read further, ken goes on to suggest a way of only updating the database every couple of minutes.  set the current time once you've updated it the first time, then check if the current time is 3 (or 4 or 5 or however many) minutes past the session time.  if it is, update the db again; otherwise, just leave it be.  that way for each user you only run an update every few minutes, which is hardly as bad as every page refresh.
  12. there's a discussion about this here: [url=http://www.phpfreaks.com/forums/index.php/topic,95397.msg381689/topicseen.html#msg381689]http://www.phpfreaks.com/forums/index.php/topic,95397.msg381689/topicseen.html#msg381689[/url] have a look, and let us know if you're still murky about how to do it. OOP is merely a different approach to doing a task, it isn't necessary to do any job in particular.  its pros and cons are heavily debated (even on this forum), so let's not start another one here, lest we stray from the actual question.
  13. my post was suggesting using output buffering, of which one of the functions is ob_start().  have a look in the manual if you want to go that route.  very few issues are solvable simply by adding one function, a little reading is always involved. to fix it, REMOVE OUTPUT BEFORE setcookie().  that was the simpler solution, and the solution first mentioned.  move your <DOCTYPE> output to below where you process the login, and specifically, where you use setcookie().  this may require a restructure of your code (so that you manage to get the DOCTYPE out before you echo anything) such as putting any errors into a variable first and echoing it later, but you've gotta give a little to get anything.
  14. i use editpad lite.  really the only functionality i need is goto line, adjustable colours, and tabbed files.  a parser would be nice, but since i edit directly in my localhost, its merely a matter of visiting in my browser.  syntax highlighting might be nice, ill try the others. for simplicity (and a marginal step above notepad), editpad lite is worth a download.
  15. well it's hard to say, since you've edited your post to remove everything, but i'd guess that you've still got output happening before you run setcookie().  what does the page look like up to and including those lines?
  16. is it so hard for people on these forums to at least glance at the pinned topics first? [url=http://www.phpfreaks.com/forums/index.php/topic,37442.0.html]http://www.phpfreaks.com/forums/index.php/topic,37442.0.html[/url] see that topic for your answer.
  17. then try using double quotes, as i'd said: [code]require_once( "../moduels/Roster/settings.php" );[/code]
  18. what are you using to express the path?  single quotes will not translate the path, so maybe try using double quotes to enclose the filename/path.  either way, seeing some code might help.
  19. it would be the latter format for the if() statement (ie. one condition for every possible extension), but three things: 1.  i would suggest simply putting all of your allowed extensions into an array and checking if the extension is in that array or not using in_array() (check the manual on the syntax). 2.  your logic is flawed.  it will check if the filename isn't set OR the extension isn't zip OR the extension isn't sit, etc.  it can't be both sit and zip at the same time, so it will always fail.  you'll need to change the extension checks to && (and operator).  using an array greatly simplifies this statement. 3.  strrchr() returns the '.' in the extension as well.  either change your allowed extensions to include the period or use substr() to remove the period in the file's extension (see manual for syntax).
  20. your array notation/usage is a little fudged up for your purposes.  it should work fine if you go: [code]<?php while (stuff = stuff) {   $search["{$row['searchterm']}"]++; } ?>[/code] this should yield an array of format $search[search_term] = searchterm_count.
  21. the error is that you forgot to add a closing double quote to the end of your SQL query.  that will fix the parse error, but it won't fix your query. for good practice, one should only select from the database the fields one wants.  * should only be used when you will literally use every field from a table.  furthermore, during multi-table calls, you must explicitly specify which field is coming from which table via table.field notation.  this INCLUDES where clauses.  it sounds like the type of query you're after is: [code]SELECT cms_stories.story_id AS sid, cms_pictures.photo AS photo FROM cms_stories, cms_pictures WHERE cms_stories.story_id = cms_pictures.story_id ORDER BY sid DESC LIMIT 1[/code] this ties every 'photo' field in cms_pictures to its matching story_id in cms_stories.  that being said, it seems like you could just run this query on cms_pictures alone and order by the story_id in cms_pictures (unless you're actually pulling the story from cms_stories). i'll note that i'm not certain whether you can use aliases in an ordering clause (i'm pretty sure you can) - if that comes back with an SQL error, try changing "sid" in the ORDER BY clause to cms_stories.story_id. hope this helps.  what i want to stress most is to get into the habit of [u]only pulling what you need to pull from the database[/u].
  22. [b]Q:  Why am I receiving an unexpected $end parse error on the last line of my code?[/b] A:  if you're experiencing this type of parse error, it is almost ALWAYS because of a missing closing brace or quote, making the script think it should still be running. check your braces and quotes carefully, making sure you've closed every set you've opened.
  23. no need to apologize, the lovely PHP function-namers hardly made it obvious that strrchr is different from strchr.  but that's a beef for another day.
  24. i didn't slog through all your code, but it sounds to me like you'd be better off using an array rather than ending your variables in _number.  perhaps restructure your data as: [code]$image[NUMBER_here] = array (   'title' => "Image NUMBER's title",   'description' => "Image NUMBER's description",   'url' => "Image NUMBER's url" );[/code] then you can simply pass through all of the $image array with a foreach and you'll have all your images displayed: [code]<?php foreach ($image AS $sub_array) {   echo '<a title="'.$sub_array['description'].'" href="'.$sub_array['url'].'">'.$sub_array['title'].'</a>'; } ?>[/code] simply build the array of info as such in each of your query's rows, assign it to a temporary array value, and make the array of image info arrays as the function's return value.
  25. nay ken, strrchr() takes the LAST instance of the needle in the haystack, and returns it from there.  that's what's so handy about the function for this purpose.  you may be thinking of strchr().
×
×
  • 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.