Jump to content

jaymc

Members
  • Posts

    1,521
  • Joined

  • Last visited

    Never

Everything posted by jaymc

  1. How can i exit out of a function to stop any code thereafter from executing, but carry on exectution the rest of the script? function beans() { echo "statement1 - "; exit(); echo "statement2 - "; } beans(); echo "hello"; In that example I would like the output to be statement1 - hello at the moment it is statement1 -
  2. Ok.. How about this scenario, slightly trickier $string = "hello go here www.website.com/jaymc please" $string = "hello go here http://www.website.com/jaymc please" $string = "hello go here website.com/jaymc please" $string = "hello go here http://website.com/jaymc please" In all 3 cases it must return the URL in any of its forms (www.website.com/jaymc, http://www.website.com/jaymc, website.com/jaymc, http://website.com/jaymc) with no trailing spaces or any other of the surrounding text
  3. Im looking for some code to extract an email address from a string, It needs to work for the following $string = "[email protected]" $string = "hello my email [email protected]" $string = "hello my email [email protected] add it please" In all 3 cases it must return [email protected] with no trailing spaces or any other of the surrounding text
  4. Great Worked fine.
  5. Im using mod_proxy with apache to loadbalancer between between 7 backend apache nodes My issue is, the application on those nodes can only ever see the proxy IP, not the client E.G I login to the website and $_SERVER['REMOTE_ADDRESS'] = proxy IP, not client I cant really make changes application level as I have IP variables defined all over the place I really need this to be done server level. Is there a way that I can get my application to see the client IP in the normal way, direct from the proxy without php code changes Cheers
  6. Ah ok, got it! Took a bit of playing around didnt realised you had to comment out \.co\.uk Cheers!
  7. I have this code $string = preg_replace('/(\[img\])(.*)(\[\/img\])/i','<a href="$2" target="BlaNk"><img src="$2"></a>',$string); I only want to parse the $string if $2 starts with "http://www.website.com" Any ideas?
  8. jaymc

    [SOLVED] MAX()

    Once again fenway strikes Thanks.
  9. I have a table which contains game scores Each game is allowed 10 scores. There are 10 games. The scores table has 100 records.. I want to create a query that will pull out the top score for each game, heres what I tried SELECT game_id, username, MAX(score) score FROM arcade_scores The MAX(score) works as it pulls out the highest score but it does not pull the same username from that row. Thats where I am stuck Any ideas?
  10. Few little glitches in that but yeh thats what I was looking for. This works perfect function days_till_birthday($birth_day_month) { $bts = strtotime($birth_day_month." ".date("y")); $ts = time(); if ($bts < $ts) {$bts = strtotime($birth_day_month." ".date("y",strtotime("+1 year")));} return round(($bts - $ts) / 86400); } echo days_till_birthday("20 Jan");
  11. Neither of your solutions will work as lets say someone has a birthday of 2 Jan 1987 I would use 2 Jan 2009 and I'd do that by checking current year and adding it onto day "2 Jan $year" But what if it was december 30th 2009, there next birthday would show as "2 Jan $year" which would be "2 Jan 2009" hence its in the past when it needed to be "2 Jan 2010" Thats the problem, its not as simple as date - date = second remaining
  12. Yeh, thats what I meant by tricky ha! Its in unix timestamp, but I can convert to anything providing it gets the job done
  13. Can anyone give me an example of how to output the number of days until a birthday e.g, my birthday is 3rd January 1987 I thought it would be easy e.g birthdate timestamp minus current timestamp but the problem is Id have to pretend the birthday was 3rd January 2009 It gets tricky if the current date is 29th December 2008 for instance
  14. DNS is no good as if a server dies a percentage of clients can not get onto my site Loadbalancing helps distrobute the load and has fail over where as if a server dies it is automatically taken out of the loop mod_proxy can also target servers that are not under as much load. It makes sense And yes, I also have lighttpd running on each of the web servers that deal with static images/files. Each server has 5GB of ram and sessions are handled in memcached etc. Its pretty nice It would be great for feedback on mod_proxy, I would be suprised if thats the bottle kneck based on its just forwarding requests as apposed to actually processing. I have loads of CPU and RAM to throw at it
  15. But surely as the apache loadbalancer is just forwarding requests, it wont be under that much strain?
  16. I have 7 web servers 1 of them acts solely as a loadbalancer The other 6 are node web servers, in other words if 4 go down I still have 2 serving my website Each node web server is set to handle 150 max connections, so 900 in total between all 6 webservers Lets just say I had 800 connections at one time, they all have to pass through the loadbalancer which means that one server is dealing with 800 connections Im worried it will cripple the loadbalancer Here are my questions 1: Because mod_proxy just forwards the request and doesnt actually process it, should I have peace of mind 2: If max clients on the load balancer hits 150, does that mean regardless of having 6 nodes each handling 150, will requests que?
  17. fenway strikes again Thanks, works perfect.
  18. syntax error near as yourScore
  19. score will = my own personal minutes_online_month in the table cache WHERE minutes_online_month > score will be everyone elses minutes_online_month in the table
  20. Hmm, not to sure how to use that. I tried SELECT count(*), (SELECT minutes_online_month FROM cache WHERE username = 'jaymc') as score FROM cache HAVING score < minutes_online_month
  21. Yeh just spotted, could not work out why it wasnt working! Cheers guys.
  22. That.. didnt work? $nums = array(0, 1, 7, 20, 40, 55, 60, 80, 81); produced this.. Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 20 [4] => 40 [5] => 40 [6] => 60 [7] => 80 [8] => 80 )
  23. Ah yes, thats how I used to do it That works apart from when $num = any of these 20,40,60,80 I need it like this Example 20 rounds to 0 40 rounds to 20 60 rounds to 40 80 rounds to 60 Any ideas to get around that issue?
  24. Do you know how I can always round down to the nearest 20, starting from 0,20,40,60 and so on Example 0 rounds to 0 7 rounds to 0 19 rounds to 0 20 rounds to 0 21 rounds to 20 36 rounds to 20 44 rounds to 40 88 rounds to 80 And so on..
×
×
  • 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.