Jump to content

woolyg

Members
  • Posts

    254
  • Joined

  • Last visited

    Never

Everything posted by woolyg

  1. Hi all, At the start of my file, I'm setting a variable so that I can timestamp (in DATETIME) the current moment: <?php $SG_now = date("Y-m-d H:i:s"); ?> I'm using the above variable to save the timestamps of the server time (UTC/GMT -7 hours) - the server is in the US. All timestamps going into the DB will be in server time. My users will be dotted around the planet, so I'm using setlocale for their area & time, after the above code: <?php // For example, London setlocale(LC_ALL, 'en-UK'); ?> So that would make: <?php $LOCAL_now = date("Y-m-d H:i:s"); ?> My question is - how would I find the difference, in hours, between $SG_now and $LOCAL_now ? All input appreciated! Wool
  2. Cool. Thanks guys for the informative replies. The project will start in english, and eventually incorporate indian characters, as well as some eastern european languages as well, so I'll take your advice, do some intense reading on the whole process, and get to changing my settings around. Waynewex - as a fellow Irishman I am beside you in mourning the death of decency, honour, and innocence of the beautiful game. Tiocfaidh ár (fraincis) lá Cheers everyone
  3. I've been reading a bit about changing tables from latin1 ut utf8. Anybody got any opinions on this also? Thanks for input so far. Wooly
  4. Thanks everyone. neil.johnson - should I run that mysql query *directly* after connecting to the DB in each case? Also, if I changed the encoding of all pages in the project to utf-8 instead of ISO-8859-1, should that suffice? I'm reading about the different types of encoding now. Cheers for the valuable info - really appreciated. Wooly
  5. Hi all, I'm facing a project that will take input of data from forms submitted by users, but in a lot of cases, the user text that is input will have non-standard characters - examples: à (HTML &agrave or &#68) ö (HTML &ouml or &#87) - semicolons omitted the html code for ease of reading Has anyone used any WYSIWYG textarea scripts, or general javascripts, that automatically changes non-standard character input by the user into its HTML equivalent, for ease of storage in a database and ease of display later on? The last thing I want to have display on the site is those annoying little boxes when a browser can't understand a character....! All input appreciated. WoolyG
  6. Nightslyr, Brilliant. Exactly the type of lightweight solution I was after - I have a tendency to go about things totally the long way. Thanks so much for your input on this - WoolyG
  7. Hey Nightslyr, Thanks for the syntax fix - I'll go about correcting this in the code. Regarding the percentage idea, I did think of this, but my poor brain couldn't think of a way to do it, without placing it all into an array, and randomly picking the outcome from the array. The main aspect I'm trying to maintain is weighting - if team 1 has 60% possiblity of success, and a 40% possibility of failure, I need to have the script pick a 1 or a 0 based on these weightings. Is there a way to do this without loading up the memory as much as I have? This is probably the difference between the match engine taking 1 second to parse a match and 15 seconds to parse a match WoolyG
  8. Hi all, I'm writing part of a game engine that needs to define the outcome success (1 or 0) of a set of numbers that two teams are being compared on. I'm looking at making the last part of the process a bit more streamlined, and wonder if anyone can help me. Current Process is as follows: 1. Collate Numeric Score for each team defined by team attributes 2. Compare the two scores, and the likelihood of success for a team 3. Taking the score comparisons into consideration, randomly choose whether the play was a success or a fail (1 or 0) Here's the code: <?php // 1. Collate Numeric Score for each team defined by team attributes // .. I'll just show the results of this section here, and assume the values are set $team1_complete_total = "5367"; $team2_complete_total = "6192"; //2. Compare the two scores, and the likelihood of success for a team // First, add the two scores up $passage_magic_number = ($team1_complete_total + $team2_complete_total); // Define a Success Array $passage_success_or_fail_array = array(); //Assuming Team 1 is in possession, Place the likelihood of success or failure into the Success Array for($t1=1;$t1<=$team1_complete_total;){ array_push($passage_success_or_fail_array, 1); $t1++; } for($t2=1;$t2<=$team2_complete_total;){ array_push($passage_success_or_fail_array, 0); $t2++; } // NOW we have an array with heaps of 1's and 0's in it //Shuffle the array shuffle($passage_success_or_fail_array); //Pick a random array placement number out of the current array $passage_random_value = rand(1, $passage_magic_number); // Define the outcome (1 or 0) $action_outcome = $passage_success_or_fail_array[$passage_random_value]; // NOW we have a 1 or 0 to say whether the whole thing was a success or a fail. // Crowd goes wild ?> (..hopefully you're still with me) My main worry is memory usage - if the $team1_complete_total & the $team2_complete_total values are MASSIVE (say around 100000), then the script above is attempting to load the sum of the two values, in 1's and 0's, into an array, which could well smash the memory of the host server machine, and the script might fall over. Can anyone think of a better way to compare the two team totals, and compare them, and pop out a randomised outcome, using those weightings? The most important aspect of this script is that there is scope for both success AND failure (I don't want the team with more than 51% of the weight to always be successful, you know?) - as a play in a sports game can go both ways, no matter how good the teams are! All input appreciated, WoolyG
  9. Hi all, I'm looking at developing a cloud application that would be hosted in the US, but each company using it would have their own 'install' on the server. I'm running through timestamping scenarios - maybe if you have the time you might add to the conversation? Because the server is in the US, if I define a global in my PHP for the exact current time, to the second as follows, it would be coded as this (say): <?php $SG_now = date("M d Y H:i:s"); //Returning 2009-09-24 13:56:26 ?> Now, say I had a customer in New Zealand, a timestamp like the one above above would be undesirable, as their timestamp for the exact same date would need to be 2009-09-25 07:56:26. Do you think using date_default_timezone_set() at the top of each page to set the current local user's time setting would work best for this type of timestamp change? If so, I'll need to allow each user to select exactly what timezone they are in when they are configuring their install, and pass that value into a $_SESSION variable. Is there a full, comprehensive list of all of the values that date_default_timezone_set() uses? I see there's one here: http://us2.php.net/manual/en/timezones.php - but it is truncated into continents. Anyone got a full list so I can easily add it into my app? If anybody has any better recommendations for parsing the local date for a user logged-in within a different timezone, please do give me some advice, I'm interested in your input. Thanks all, WoolyG
  10. Thanks Corbin, I'll look further into it WoolyG
  11. Hey, Thanks Corbin - that's exactly the insight I was looking for. I'll begin considering alternative methods for what I need to do. BTW, what did you mean by or you could write a simple PHP script that would update the files ? Wool.
  12. Hi all, Not sure which forum to put this in, so I chose this one. Has anyone done this before? Basically I'm looking at placing all of the PHP/HTML code into the DB as a MEDIUMBLOB, and calling the data as it's required. A PHP page would basically consist of the following: <?php // Connect to DB $get_page_code = " SELECT code_table.page_code FROM code_table "; $run_page_code = mysql_query($get_page_code); $display_page_code = mysql_fetch_assoc($run_page_code); $page_code = $display_page_code['page_code']; /* This sets the code as a variable <html> <head></head> <body></body> </html>..etc */ echo $page_code; ?> ..and that's all. The reason for looking into this is because the server the PHP application will be stored upon will have no FTP access (for a business's in-house CRM for example). This setup would enable very easy update of the PHP code, as the code could be deployed through a PHP/MySQL script from within the app, and easily updated by an admin on-site, rather than me going to the business and manually FTP'ing files onto the local network. My questions are as follows: 1. Has anyone tried this, and how well did it go? 2. Any noticeable performance hit/fail scenarios? 3. I'm worried about needing to call further PHP variables within the MEDIUMBLOB contents. Say I needed to echo a username halfway down the page. If I use "?>" to close the PHP echo, will that close off the echo of the MEDIUMBLOB? 4. Is it possible to make further MySQL calls within the MEDIUMBLOB data? I'm thinking that slashing all of the quotes (\") within the MEDIUMBLOB data should allow the echo $page_code; to properly parse the info... Any input appreciated. WoolyG
  13. Thanks KingPhilip, that's a big help! WoolyG
  14. Hi all, Another possibly frivolous question from me, for all who have previously developed facebook apps: I'm looking into setting up a facebook app for a charity site I'm doing, but the process on the site I've developed requires users to be logged in in order to send charity pledges to others on the site. If I set up a facebook app, it would be required to create local accounts (on the charity site DB) for everyone using the app, so that the app can connect to the charity site, and allow folks to pledge stuff to one another. My Q is as follows: if I set up a facebook app, is there a way to 'gain access' to the name and email address of the facebook user who signs up to use the app? This way, they can be signed in, pledge what they want to pledge, and the local DB of the charity site can be updated with the pledge, made from facebook. Of course I wouldn't be using the app for evil - our intentions are shiny and bright! Is this possible? All input appreciated. WoolyG
  15. Hi all, I'm currently developing a charity website (if anyone would like to lend a hand, please contact me!) and I'd like to work in some functionality as follows: A user expresses gratitude to another person, and sends them a virtual coin. The sender's IP address is saved to the DB. When the recipient picks up the coin from the site, their IP is saved also. Basically we're tracking where on the planet this coin travels, as it passes between users. (Everything prior to this point is fine & working OK). I'd like to set up a google maps thingy where we can visually see a coin's course, from the list of the IP addresses it has been to previously, up to this point - it would add a definite interactivity to the site that we're looking for. Something like What Travelpod does with plotting the location of their users: http://www.travelpod.com/travel-blog-entries/broony79/1/1220297280/tpod.html (this isn't my entry, it's a random one I've picked out ) Has anyone here used Google Maps to work out a series of locations from IP addresses? Can anybody point me to any resources? Thanks all, WoolyG
  16. ProjectFear - Perfect! Works like a charm. Thank you so much. Maq - I didn't do it that way because the original player_id's are variables from a previous query (inside another WHILE loop again), and didn't want to make my post more convoluted than necessary... Cheers, WoolyG
  17. Hi all, Is there a way to grab variables as a WHILE loop passes, and add them up to form a total at the end of the loop? For example: <?php //Get player_id $get_id = " SELECT players.player_id FROM players WHERE players.player_id='1' OR players.player_id='64' OR players.player_id='154' "; $run_id = mysql_query($get_id); while($display_id = mysql_fetch_assoc($run_id)){ // WHILE 130 $player_id = $display_id['player_id']; //Get the value of this player's speed $get_speed = " SELECT player_info.speed FROM player_info WHERE player_info.player_id='$player_id' "; $run_speed = mysql_query($get_speed); $display_speed = mysql_fetch_assoc($run_speed); $player_speed = $display_speed['speed']; } // WHILE 130 $total_speed_of_all_players = //???????? ?> I hope this is clear enough. Can anyone shed any light? Thanks, WoolyG
  18. Hey Carth, Thanks for the answer. I've had a brainstorm and decided to do a simple str_replace(). If I drop the dollar sign from the start of the sex_posssessive_single variable within the DB, and do the following: <?php $sex_possessive_single = "his"; $commentary_ttr = ("sex_possessive_single"); $commentary_rt = ($sex_possessive_single); $commentary1 = $display_query['commentary']; $commentary = str_replace($commentary_ttr, $commentary_rt, $commentary1); ?> Once I change the entry within the db for the commentary to: The keeper falls backwards, and somehow the ball hits the base of sex_possessive_single feet, preventing catastrophe. The right defender takes the ball under control, and moves off. .. the str_replace changes: sex_possessive_single to his .. and it prints beautifully. Thanks!
  19. This could be an easy one.. or just not possible:) I'm trying to write a commentary engine for a game idea that I'm doing. I'm declaring standard variables at the start of the page, then what I want to do is call a commentary bit of text from MySQL. The commentary itself contains references to PHP variables declared earlier in the page. However, when I call the text from the DB, the variable is printed in plain text on the page - it doesn't refer to the variable declared earlier in the page. example: <?php $sex_possessive_single = "his"; /* $query = " SELECT * FROM commentary WHERE ball_start = '$starter' ORDER BY RAND() LIMIT 1 "; $run_query = mysql_query($query); $display_query = mysql_fetch_assoc($run_query); ... as a result of the above query, the output is */ $commentary = "The keeper falls backwards, and somehow the ball hits the base of $sex_possessive_single feet, preventing catastrophe. The right defender takes the ball under control, and moves off."; ?> The commentary being printed is: The keeper falls backwards, and somehow the ball hits the base of $sex_possessive_single feet, preventing catastrophe. The right defender takes the ball under control, and moves off. I was expecting it to say: The keeper falls backwards, and somehow the ball hits the base of his feet, preventing catastrophe. The right defender takes the ball under control, and moves off. - I want the output to say HIS where it says $sex_possessive_single. Is there a way to place a PHP variable in the form of $variable into a mysql table (varchar field) and have the variable populate properly upon recall? I hope this is clear enough to understand. Cheers all, WoolyG
  20. Hi all, Please check this out: <?php $get_subscribed_players1 = "SELECT game_subscriptions.user_id FROM game_subscriptions WHERE game_subscriptions.game_id='".$game_id."' AND game_subscriptions.active='1'"; $run_subscribed_players1 = mysql_query($get_subscribed_players1); //Get the array of currently active players in this game for($k=1; $k<=$num_subscribed_players1;){ // FOR 107 while($array_subscribed_players = mysql_fetch_assoc($run_subscribed_players1)){ // While 107 $array_user_id = $array_subscribed_players['user_id']; if($k!=$num_subscribed_players){ $array_comma = ",";} else {$array_comma = "";} $array_of_subscribers.="'".$array_user_id."'".$array_comma; $k++; }// While 107 }// FOR 107 $needle = '10'; $test_array = array($array_of_subscribers); if(in_array($needle, $test_array)){ // IF 138 echo "Signed in - In Array"; } else if(!in_array($needle, $test_array)){ // IF 138 echo "Signed in - NOT In Array"; } // IF 138 ?> The code should be seeing that 10 is part of the array, and saying "Signed in - NOT In Array", but it's not seeing the number in the array. Can anyone see what I might be doing wrong here? Thanks, Woolyg
  21. Yesideez - thanks a million, that answers my question perfectly. Solved! WoolyG
  22. Hi all, Apart from this topic title sounding marvellously intelligent, I'm looking to see if this can be done. Here's what I'm trying to do: Users upload videos to my site. I'm trying to grab a list of their active videos, and list the video details in an email to them, as a kind of update. Code: <?php $user_id = '1'; // Define the user_id //Find out if they have any active adverts $get_users_active_adverts = " SELECT * FROM videos WHERE videos.user_id='$user_id' "; $run_users_active_adverts = mysql_query($get_users_active_adverts); $num_users_active_adverts = mysql_num_rows($run_users_active_adverts); //If they have one or more adverts, send them an email with their stats if($num_users_active_adverts > = '1'){ // IF 71 while($display_users_active_adverts = mysql_fetch_assoc($run_users_active_adverts)){ // IF 73 $video_id = $display_users_active_adverts['video_id']; $video_name = $display_users_active_adverts['video_name']; echo "$video_name<br />"; // ****** } // IF 73 } else { // IF 71 //They have no active adverts - Send them an email prompting for them to use the service. } // IF 71 ?> If I echo'd the results, as above, I'd get a list of video names, as per: echo "$video_name<br />"; ..but what I'd like to do is put all of the iterations of $video_name<br /> into a variable, that I could then place into an HTML email and send to the user. If you can follow my idea, can anyone help? All input appreciated. WoolyG
  23. Hi all, I'm trying to read info from an XML feed and print it to my PHP page. the XML feed is here:http://xurrency.com/nzd/feed And the code I am using is here: <?php # INSTANTIATE CURL. $curl = curl_init(); # CURL SETTINGS. curl_setopt($curl, CURLOPT_URL, "http://xurrency.com/nzd/feed"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0); # GRAB THE XML FILE. $xmlTwitter = curl_exec($curl); //echo $xmlTwitter; curl_close($curl); $xml = simplexml_load_string($xmlTwitter); foreach($xml->xpath('//item') as $k => $item) { // FOR 17 $creator= $item->xpath('//dc:creator'); echo $creator."<br />"; } //CLOSE FOR 17 ?> If I un-comment "echo $xmlTwitter;", it displays all of the XML, but I'm having trouble picking the info out of the file. Could anyone please help? Thanks, WoolyG
  24. Hey all, How many tables are too many in a MYSQL DB, do you think? I've divided up all my info into 2-field tables, all linked by indexes. At the moment, there are about 70 tables, but that could go up to about 100. Has anyone had any issues with DBs with this amount of tables in? Cheers, WoolyG
×
×
  • 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.