Jump to content

joel24

Members
  • Posts

    760
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.roboroster.com

Profile Information

  • Gender
    Male
  • Location
    London

joel24's Achievements

Member

Member (2/5)

0

Reputation

  1. well if it's only calling it once and you're receiving a 403, either you've been manually blocked or the IP of your shared host has hit it too many times. Can you run that script successfully from another IP? i.e. your local machine? that way you can debug - or contact geoplugin enquiring as to why you're receiving the 403 from your IP.
  2. "Unless otherwise indicated, all photographs on photo.net are copyrighted by the photographers, whose permission is required for any usage."
  3. your jsfiddle works fine though the css has the following declaration which is hiding the radio button. [type=radio]{display:none} if you change that to [type=radio]{display:block;} and then wrap each image and the associated radio button in a div and float to the left you can group them and play with the css.
  4. ahh sorry, as the substr counts the first char as 0, it needs to go from 0-3 Also, my loop was removing the $i position character rather than a random one... I've put in a method which will return a random number which has not been removed from the string as yet. I've done some tests and it's working - let me know if you've any queries about the code function getRandomCharToRemove(array $alreadyRemoved, $strLength) { $random = rand(0,$strLength-1); //substr starts from char 0 so we need to subtract 1 from strlen return (!isset($alreadyRemoved[$random])) ? $random : getRandomCharToRemove($alreadyRemoved,$strLength); } $maxCharsToRemove = 2; $word = 'bees'; $strLength = strlen($word); $charsGettingRemoved = rand(1,$maxCharsToRemove+1); $charsRemoved=array(); for ($i=0;$i<$charsGettingRemoved;$i++){ $randomCharToRemove = getRandomCharToRemove($charsRemoved,$strLength); $charsRemoved[$randomCharToRemove]=substr($word,$randomCharToRemove,1); $word = substr_replace($word,'*',$randomCharToRemove,1); } echo "Your word is: $word<br/>The letters missing are: " . print_r($charsRemoved,1)."<br/>Len: $strLength<br/>Chars removed [position => letter]: $charsGettingRemoved";
  5. Can you post the full trace? And can you check that your APP_ENV param is set in your /.env file and let us know what it is?
  6. session_start(); $_SESSION['currentWord'] = 'bees'; $word = $_SESSION['currentWord']; $length = strlen($word); $maxCharsToRemove = 2; //you could swap this for a algorithm based on the strlen (i.e. ceil($length/3)) -- lets round up incase the division is less than 0 $charsGettingRemoved = rand(1,$maxCharsToRemove); $charsRemoved=array(); for ($i=1;$i<=$charsGettingRemoved;$i++){ $charsRemoved[$i]=substr($word,$i,1); $word = substr_replace($word,'*',$i,1); } echo "Your word is: $word<br/>The letters missing are: " . print_r($charsRemoved,1)."<br/>Len: $length<br/>Chars: $charsGettingRemoved"; //and when teh users posts the form, concatenate all of the posted characters and see if it equals to $_SESSION['currentWord'] and then for the html <input type="text" name="question_1_letters[]" class="inputs" maxlength="1" value="" /> <input type="text" name="question_1_letters[]" class="inputs" maxlength="1" value="" /> <input type="text" name="question_1_letters[]" class="inputs" maxlength="1" value="" /> <input type="text" name="question_1_letters[]" class="inputs" maxlength="1" value="" /> the above html will be accessible in an array of $_POST['question_1_letters'] and will automatically receive indexes... so you can implode and see that it equals to the question 1 word if (implode('',$_POST['question_1_letters'])==$_SESSION['currentWord']) //they got it right else //they got it wrong apologies for rewriting your code, i started out fixing yours though thought it easier to understand written this way... and easier to scale
  7. what is your pollsession function? it's calling another api so shouldn't be initiating another request to geoplugin. Could you show us the pollsession() function and also put the following line on your script after $xml = simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".$ip); // put after the above line which is already in your code $_SESSION['geoplugin']=(isset($_SESSION['geoplugin'])) ? $_SESSION['geoplugin']+1 : 1; echo "<p>Calling geoplugin {$_SESSION['geoplugin']} times</p>";
  8. is your min/max being set in the sql query? add in a var_dump($min,$max,$_POST); exit; and let us know the response
  9. not entirely sure what you're after - you want the previous/next buttons to trigger the same ajax method and update the href of the previous/next?
  10. You should be using ID instead of class if the element is unique? i.e. you're not updating multiple elements? you can add a class also if you've got some css <a class="link></a> (works correctly running ajax request with url of wordpress post) <a id="next" href="#"></a> (should run ajax request with url data.next_url) <a id="previous" href="#"></a> (should run ajax request with url data.previous_url) and then use your javascript to assign the href value when the ajax is returned <script> $(document).ready(function(){ $('.link').click(function(){ if($('#content').css('display') == 'none'){$('#content').toggle();} id = $(this).children('span.title').attr('data-id'); $.ajax({ url: "http://localhost:8888/projects/superfreerespo/" + id, method: "GET", data: {json: 1}, dataType: "JSON"}).done(function( data ) { $("#game-name").html(data.post.title); $("#game-reels").html(data.post.custom_fields.reels); $("#game-paylines").html(data.post.custom_fields.paylines); $("#game-minBet").html(data.post.custom_fields.min_bet); $("#game-maxBet").html(data.post.custom_fields.max_bet); $("#game-jackpot").html(data.post.custom_fields.jackpot); $("#game-info").html(data.post.custom_fields.game_info); // -------------- // You can see below I can log the prev/next values to console //console.log(data.next_url); //console.log(data.previous_url); $('#next').attr('href', data.next_url); $('#previous').attr('href', data.previous_url); // The above json values should be attributed to the next & previous links accordingly and run the ajax request with those url's }) })
  11. which of your six posts would you like replied to? http://forums.phpfreaks.com/topic/295862-rerun-ajax-request-with-variable-url/ http://forums.phpfreaks.com/topic/295861-rerun-ajax-request-with-variable-url/ http://forums.phpfreaks.com/topic/295860-rerun-ajax-request-with-variable-url/ http://forums.phpfreaks.com/topic/295859-rerun-ajax-request-with-variable-url/ http://forums.phpfreaks.com/topic/295858-rerun-ajax-request-with-variable-url/ http://forums.phpfreaks.com/topic/295857-rerun-ajax-request-with-variable-url/
  12. is it a shared webserver? I attempted loading the geoplugin from my local host and repeated a large number of times and now i'm getting a 403 forbidden also. You'll need to either buy a licence for geoplugin as if you're on a shared host, any other users on the same box will have the same IP address and if they happen to be using geoplugin it will impact on your usage... though you'll want to get a unique IP address also, otherwise you buying a licence will entail that other users on your shared host will be able to use your licence.
  13. just use javascript to update the theme when the dom loads, you don't need to know these values in your php script. screen.width; screen.height;
  14. oh i see, I think you'd be best off using a basic relational database and storing the ID rather than having fields with names of 1,2,3 and sending back multiple form fields and expecting to match up the numeric form element name values rather than human readable values... I would create a form table, have that as an incremental ID in that table. Then join each form element (id,type,name,value etc) to that so add an extra row in there of formId And when you submit the form to update, send across a hidden form element with formId... that way you know when you're doing the update you can update where formId = x and name = y since a form shouldn't have the same form element name twice. In your case, you can maintain your current code (which I'd advise against) and simply change the form element name to be myinput[$id] so it passes back an array of the form elements to the server and can loop through those to process.... i.e. //lets echo out the form elements foreach ($formElements as $row){ echo "<input type='{$row['type']}' name='myinput[{$row['id']}]' value='{$row['value']}' />" } now to update the form elements, foreach ($_POST['myinput'] AS $k=>$e) { $sql = "UPDATE yourtablename SET value="{$e}" WHERE id='$k'"; mysql_query($sql); }
  15. could you please post your db schema? tad confused what you're trying to do... as ginerjm said, if you're updating a row you should just be passing back the id of the row in question using a hidden form field and the user accessible form fields would have names which pertain to their respective database column.
×
×
  • 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.