Jump to content

RussellReal

Members
  • Posts

    1,773
  • Joined

  • Last visited

Everything posted by RussellReal

  1. Not with php, atleast I'm 90% sure you can't with php, unless you modify your apache config files, which you probably can't due to permissions issues.. what you CAN do, is contact your hosting provider, ask them to impliment wildcard subdomains.. and so whenever you go to whateverYouWant.yourdomain.com it'll know to go to whichever directory, in there you use modrewrite (htaccess rewrite engine) to detect the subdomain and reform the request to something similar to: yourdomain.com/whateverYouWant/
  2. you have the for loop outside of the foreach loop..
  3. why would you die() on errors, you should pass it to an error object, and check if any errors have accumulated every step of the user verification process. and your use of the :: operator is completely wrong, you don't want the information in a user class to be static, you want it to be dynamic, which you'd use -> operator for.
  4. you cannot do this through a web server, however you could do this through CLI, and you would use the sleep function.
  5. The minimum interval for a cronjob is 1 minute. Ken yes, I know, but that means 1 script is being ran every (24*60*60) times per day, to do something that doesn't need to be completely automatic 3 seconds is perfectly fine I thought, but you could run it every 1 second for sure..
  6. you're probably trying to use the :: operator instead of ':', however, that will not work I don't believe, replace your ':' with '->' and see where that gets you
  7. You should look at http://jquery.com/ it makes this so so easy, but if you wanna do it like this, you will have to from reserv_test.php do something like this code: <?php // connect to db $reservations = array(); $q = mysql_query("SELECT r_id FROM reservations WHERE r_taken = '0' AND r_month = '{$_POST['month']}'"); while ($x = mysql_fetch_assoc($q)) { $reservations[] = $x; } echo json_encode($reservations); ?> and in the js you will get your response from the server, if you're using jQuery it will already process the JSON from the response, however, if you're using str8 ajax in javascript, you'll need to execute your response var reservations = eval('('+xmlHttpRequest.responseText+')'); and there you go, reservations will hold an object of all available reservations!
  8. what you should do, buy a cheap $2 webhosting that supports cron, run the cron job for every 2 seconds or 3 seconds the php file would simply be to check if there are any queued calls... then dispatch them, then wait to be activated again.. whichever company you work for wouldn't have a problem with paying the extra $24/year for this to work out.. thats the easiest sollution, aswell as most practical. however, if you want to use sleep(), for over 12 hours, you're most likely gonna want to double check with Yahoo! Small Business if its okay
  9. I'd say the best would be 1 or 4.. 1 would be the best choice for me tho
  10. This is what I would recommend: http://jquery.com/ http://api.jquery.com/category/ajax/ You write a script that does session_start(), checks that there's a valid user and if so, calls an update function you write that will update the status of the user -- usually via a datetime column in the database named something like lastseen. In your jquery you make calls to this script based on the setInterval() javascript function. One reason not to use the onbeforeunload() event as suggested by russelreal, is that this would be problematic in certain circumstances where for example, someone opens up multiple tabs to your site for the same session, which is easy to do with current browsers. If you assume that because someone closed a tab they were logging out, you could get in a situation where you logged someone out who still had an open window on your site. yes but they would be inactive until they visit another page anyway when they visit the next page their session will be touched and they'll be "active" again.
  11. the Location: header is a redirect for the browser, it doesn't execute anything until the user's client (browser) follows the redirect, but it will be unable to follow the redirect because the destination is outside of the public directory. what you CAN DO is include that file include('../../testing/test.php');
  12. I'm sorry, where it says &=, change that to =&
  13. longpolling #1 BEST answer to this, but server limitations and browser limitations mess you up for example, google chrome only allows 2 or 3 live connections at a time, which means if they have 3 or 4 instances of your web app, one of those will be inactive until it can secure a slot to start a connection. server limitations vary but its mostly because servers offer limited connections at the same time.. an example of a longpoll is simply: 1. request a php file from your server (longpoll.php) with javascript and wait for a return 2. in longpoll.php you will throw yourself into an infinite loop, everytime the loop LOOPS you will check the database for new results, messages, etc. IF and WHEN you get a return from the database, you will return it to the browser.. 3. browser will get back data or the connection will time out, handle the data you've just received, be it a new message or a friend coming online etc. 4. repeat steps 1-3 immediately this will get your live chat on the right track
  14. yes I know what AJAX is, but AJAX is simply Javascript with use of XML Streams... I have used the same general idea on one of my sites as what you have mentioned, but I stuck to the Original Poster's guidelines with my answer.. I wasn't bashing your answer. He wanted to know when the user changed URLs, yes ofcourse you can't actually GET the new URL, but you can use this to know when the user: A. CLOSES THE BROWSER B. NAVIGATES AWAY FROM THE CURRENT PAGE. That seems to be his ultimate goal here then he could use AJAX inside of the onbeforeunload to send a request to the server, the server doesn't even have to give a response, make it a 1 way transaction saying that the user has left that page
  15. well if you're gonna go with ajax, you could just go with an onbeforeunload event... but I don't know the browser support of that event.
  16. same issue exists IF you use COOKIES to handle PHPSESSID, but if you append the PHPSESSID to the url, than you can basically have multiple sessions per user.. but asside from the above, which would be easier, if you want to limit 1 session per user, and just thread the session out to accommodate multiple tabs you could use the same logic as the first thing I mentioned.. With minor differences.. When a user goes to step1, set a variable in 2 places... E.G. <?php session_start(); $a = rand(1,1000); for ($i = rand(1,10); $i < rand(11,20); $i++) $a += rand(1,rand(35,1000)); // KINDA ensures a random number $ref &= $_SESSION['tabs'][$a]; $ref = array(); // use $ref for the rest of STEP 1 ?> ^^ in the form of step 1, 2 AND 3.. include a hidden input like so: <input type="hidden" name="tab" value="<?php echo $a; ?>" /> and then in STEP 2 get the current $ref for the current tab by doing this: <?php session_start(); $ref = $_SESSION['tabs'][$_REQUEST['tab']]; ?> the only downside to method #2 is if a user hits the backbutton all the way to step 1, a new tab id will be generated, and then the session file could get huge if that guy likes to refresh on step 1 aswell.. a whole lot so theres drawbacks to both, you can decide which one you like better
  17. sessions are the best possible solution.. how a session works is easy to understand, and you'll maybe be able to use them better. #1 when you call session_start() it will look thru the REQUEST variables (Cookie, Post, Get) looking for PHPSESSID. When PHP finds this variable it will access it find the string contained within, and open up a file.. if there IS NO PHPSESSID then it will create that variable (which is why it needs to be called before any output.. setting a COOKIE requires no output to be sent) #2 once the file is located which contains your user's SESSION.. it is opened and loaded into a regular-not-so-special variable called $_SESSION #3 then you will use $_SESSION just like you'd use any other array.. except, anything you put into $_SEsSIOn or take away from $_SESSION will be recorded inside of that user's session file .
  18. we are not talking about a text file, we're talking about a text input.. its always just an \n and either way.. \r is just a carriage return \r\n is not a different way of a new line.. if anything even if there happened to be a carriage return found.. a simple trim() would do fine when you add my lines back to the main array.. so gf <3
  19. this will not work in PHP You CAN accept the form on your own server, you CAN forward information to paypal.com via cURL which might be able to FOOL PayPal's security features.. but you CAN'T forward a user to another page with PHP while maintaining and modifying POST and GET variables..
  20. $x = explode("\n",trim($_POST['text_field'])); foreach ($x as $line) { $y = explode("-",$line); mysql_query("INSERT INTO `table` (common_name,genus_name,native_to) VALUES('{$y[0]}','{$y[1]}','{$y[2]}');"); } however this could also be done with only ONE insert query.. but it would be handled something like this: $x = explode("\n",trim($_POST['text_field'])); foreach ($x as $key => $line) { $vals = ($y = explode("-",$line)); foreach ($y as $key => $value) { $vals[$key] = "'{$value}'"; } $x[$key] = '('.implode(",",$vals).')'; } $x = implode(',',$x); mysql_query("INSERT INTO `table` (common_name,genus_name,native_to) VALUES{$x}");
  21. $x = true; while (true){ if ($x) fwrite($fp,"I AM THOMAS"); else fwrite($fp,"HELLO WORLD"); $x = !$x; sleep(5); }
  22. use imageftbbox with '(' then '2.25' then '-' then '1.75' then ')' and place them mathematically, I gotta run to the eye doctors so I can't do this for ya, but ^^ thats the way you would do it, the 1 string '(2.25-1.75)' would be output with four calls to imagefttext, cya
  23. I don't quite understand the question, but I'll try and help anyway (: From what I gather you just want simply a way to calculate a different shade of red, and a different shade of green, for each level of energy/entropy.. ok! so heres how we'd go about doing this! <?php $levelMax = 256; // highest shade of any color in the RGB spectrum(?) /* change these whenever you want to */ $x = 1.8; $y = 1.2; $max = 3; /* ^^ those are the editable things lol */ $red = ($x / $max) * $levelMax; // tiered red $gre = ($y / $max) * $levelMax; // tiered green $color = imagecolorallocate($image,$red,$gre,0 /* blue change to whatever */); ?>
  24. np bro, I'll explain it IFNULL simply checks if parameter 1 is null, if it is, return parameter 2, if it isn't null, it returns parameter 1 (to make it make sense! IFNULL(param1,param2) ) LEFT JOIN is an OUTER JOIN, INNER JOIN is self explanatory The difference between outer joins and inner joins, outer joins will not fail the selection if the ON parameter doesn't match, it will simply join a NULL ROW so basically if there is NO ROW in `icons` for the address 'playground' then it will instead of not pull a row for 'playground' it will pull playground from `nvc` and a null row from `icons`.. so back to IFNULL, because IFNULL tests param1 against NULL, if `icons` doesn't have a row for the current `nvc` row, IFNULL(icons.icon,'defaultPicture.gif') will naturally return parameter2 which is the default picture for rows without a thumbnail I gotta run out ! Thanks for choosing PHPFreaks for your PHP help <33 *got paid $5 to say that.. cough cough* *not really, I just love this forum!*
  25. $query = "select address, IFNULL(icons.icon,'defaultIcon.gif') As icon from nvc LEFT JOIN icons ON (icons.addy = nvc.address)"; sorry just realized I misnamed the function IFNULL <3 SORRY AGAIN I used inner join instead of LEFT JOIN D:
×
×
  • 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.