Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by codefossa

  1. The required attribute is being used on your file select. Remove that and it will become optional.
  2. Your parameters aren't quite right for preg_replace_callback(). <?php $new_str = preg_replace_callback('/regexp/', function($m) { // $m is an array of the current match }, $str); ?>
  3. To get a new number each time without some sort of bad luck, I would usually suggest using a timestamp. It's in milliseconds in JS, so unless you go way overboard on a couple submits ... To skip the whole need of using random numbers to avoid caching, you could just use a post instead of get. $.post('/map_data.php', { 'mid': 1 }, function(data) { $('#summary').html(data); }); Then you need to use $_POST instead of $_GET, but caching won't be an issue. If you really did want a random number, PHP could generate that with rand().
  4. As an alternative to what's shown above, here's another option: <?php $start = 1; $end = 5; // Using str_repeat() for ($i = $start; $i <= $end; $i++) { echo str_repeat('*', $i) . "\n"; } // Going Both Ways $dir = 1; for ($i = $start; $i > 0 && $i <= $end; $i += $dir) { echo str_repeat('*', $i) . "\n"; if ($i == $end) $dir = -1; } ?> The First Option Output: * ** *** **** ***** The Second: * ** *** **** ***** **** *** ** *
  5. To pull the items of an array and append them to a string you would use: "your url ..." . $corpid[$x] Also note that you should probably check the array key exists, as you're doing 1 and 2 in your loop as $x when your array keys are 0 and 1. Try something more like .. // Number of elements in the array. $corpid_len = count($corpid); // Loop through starting with 0 and ending with the count - 1 for ($i = 0; $i < $corpid_len; $i++) { $url="https://api.eveonline.com/corp/CorporationSheet.xml.aspx?corporationID=" . $corpid[$x]; }
  6. $('#checkboxes input').change(function () { /* Your stuff */ });
  7. Without you giving us the value of $post_article, I would have to guess that there's a single quote in it causing your JS to fail. You would need to replace ' with \'.
  8. You are missing the period for $.getJSON(). If that's not your issue, you should check your JS console to see if you're failing to parse the return. Maybe output the return in your console and see what that is. You can just do a $.get() and $.parseJSON() if you want to be able to output the data as well as parse it.
  9. You just need something to tell which should show / hide. You can use the value in your above example and have that be the value of a parameter on the other selects. When onchange triggers, you can hide them all then show the one(s) you want. https://jsfiddle.net/aLkz2aw1/
  10. https://jsfiddle.net/xvfp1nqL/ You can just use the .hover() function in jQuery. You can also set an attribute like data-bg if you want to set a different background for each element you're hovering. You would have something like ... https://jsfiddle.net/xvfp1nqL/1/
  11. It looks like the only thing you're missing is getting the value of the input, or I'm missing what the question actually is? Here's what I think you're wanting. https://jsfiddle.net/bme5ahjs/
  12. Your ID for 'targettemp' has a space at the end causing your JS selector to fail.
  13. http://jsfiddle.net/y3j81fr0/ You can change the input type to text to see it happen. Just setting the value to: (new Date()).getTime()
  14. Add some PHP to the top of your page setting the header to not cache the page. <?php header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> Or if you must use plain HTML. <meta http-equiv="expires" content="Sun, 01 Jan 2014 00:00:00 GMT"/> <meta http-equiv="pragma" content="no-cache" />
  15. That should work fine. // http://jsfiddle.net/qcr1qws4/ var first = "Thomas"; var second = "Jack"; if (first == second) alert("Same Name"); if (first == "Thomas") alert("First person's name is Thomas.");
  16. I'll just say exactly what I was doing then. I have a table. id - timestamp - ip - user I get anywhere from a couple hundred to a 100,000 to add to it at any time. I need to check if the ip/user combo exists before adding it. The way I was doing it was sadly extremely slow because I wasn't aware you could do this, so I had to check if it existed the long way. So, you didn't really answer my question, but gave me an awesome alternative because now I'm able to just add them and it will take care of checking for duplicates. I guess that's probably where the confusion was because you went in a bit of another direction and it happened to be exactly what I needed.
  17. Sorry for not saying it clearly but you've given me my answer better than I ever expected. I didn't know you could use a combination of columns with UNIQUE so now, I can use that with INSERT INGORE and it's perfect. Thanks so much.
  18. It's set up with (id, ip, name) and I need to check that the ip and name combination don't exist before inserting. I do this in one query (kind'a) but I would like to check more of them at once. It sounds like you're saying to insert them all into another table, but that would add more time to this I would think? Maybe an example of what you mean would help me understand.
  19. Is it possible to check if multiple rows exist at the same time. For example, if a row with the id "1" and another row with id "2" exists, and return something like true then false if only the first exists? I have a file that provides tens of thousands to check and it takes forever. I know this sounds bad off the start, but it's not something that is run normally. Only to update my database with new additions. Is there any good way to check a lot at once? I know you can insert many at a time and save a lot of time.
  20. Something like this would do it, but note that JS Fiddle won't allow you to get sent to another page. // http://jsfiddle.net/4d2xx7n1/ $(document).ready(function() { var url = "http://google.com", badImage = "http://darealtalk.files.wordpress.com/2013/02/smile.jpg"; $("img").each(function() { if ($(this).attr("src") != undefined && $(this).attr("src") == badImage) { if (confirm("Image Found! Click OK to redirect.")) $(location).attr("href", url); break; } }); });
  21. That's because getTimezoneOffset() returns the offset in minutes rather than hours. The pad() function you have there just repeats a string and adds it to the beginning of the string you give it, in this case the time. That shouldn't have changed the outcome of getTimezoneOffset() though. It should have return something different if you changed your system's timezone. For example, I get 240. One note. Your line offset = ((offset <0 ? '-' : '+') + is wrong. You want to switch the strings because 240 is GMT-4 and -120 would be GMT+2.
  22. You're better off not bothering with PHP. Use Javascript. You can make Greasemonkey scripts for your browser and that could handle it all. Note that you should probably just keep track of cookies rather than your actual login information so the worst that can happen in most cases is session hijacking. That can still suck, but usually not as bad as giving up your password. As for displaying it, you'd have several options. Use any site and use their custom 404 page, or add something to the URL in the homepage likie "?action=dispalyInfo" and you can completely' wipe the page and create your own with JS. This is all client-sided of course, as I don't think you'd want to have your information available to remote users? If you do for some strange reason, then I guess you could store it and use PHP, but I can't imagine that being your goal.
  23. If you meant you wanted the javascript outside of the body tag, then maybe this would be what you wanted. Left the option for adding more JS after load rather than just one function called, but there's tons of ways to do that. <head> <script type="text/javascript"> // Wait for load window.addEventListener("load", function() { // Do whatever .. getParameterByName("url"); }, false); </script> </head> <body> <!-- Added "#" as target to avoid moving pages without JS --> <a href="#" id="urllink">Click Here</a> </body>
  24. Does mysql_real_escape_string() work? Also, make sure the colation (not sure if I spelt that right) supports it. general_utf8 should be good.
  25. Jacques1 is correct, but your second if statement could just go inside the first to solve that. <?php if ( /* true || false */ ) { $val = new Val(); $valon = $val -> check($_POST, array('a', 'b', 'c')); if ($valon -> passes()) { $use = new Use(); // ... } } ?>
  • 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.