Jump to content

justsomeguy

Moderator
  • Posts

    31,575
  • Joined

  • Last visited

  • Days Won

    77

Everything posted by justsomeguy

  1. You what now? You're going through a project and deleting code? Who has judged the code to be extraneous, is it you? Do you have examples of the things you've decided to remove, just so I know what the situation is? Really though, Ingolme is right: No developer has the time or motivation to do anything like this. This is not the goal of any professional. But for some reason you've decided to need to delete pieces of code from the project, and do you still expect the project to work the same way? I don't get it. It's a weird attitude to take, "this developer is sabotaging their own project so I'm going to delete a bunch of their code and still try to use their software." Now, your error about an undefined function has a single possible reason: you're not using PHP 7, as Ingolme pointed out. That function is part of the CSPRNG extension, and this is the installation page for it: http://php.net/manual/en/csprng.installation.php As you can see, they are part of the PHP core. So, if they are not defined in your environment, then the only possibility is that you are not using PHP 7. But really, the bigger question is why you're trying to go through and edit a project's code in general. You do not have to do that. If it doesn't work, it's not because their code is bad, it's probably your environment. You specifically should never need to alter the code of any project you're trying to use, as long as it works in your environment. Trying to do that means that you have taken yourself out of the upgrade loop, you can't upgrade that software to fix bugs without going through and doing all of your changes again, and if you didn't document everything you did then that's going to cause problems. Hopefully you're not just planning to never upgrade.
  2. That's the UTF-8 BOM. You can use this to strip the BOM from the beginning of a string: // check for a variety of byte order marks at the beginning of the string and remove them if present function strip_bom($str) { $boms = [ pack('CCC', 0xef, 0xbb, 0xbf), # UTF-8 pack('CC', 0xff, 0xfe), # UTF-16 (BE) pack('CC', 0xfe, 0xff), # UTF-16 (LE) pack('CCCC', 0x0, 0x0, 0xfe, 0xff), # UTF-32 (BE) pack('CCCC', 0xff, 0xfe, 0x0, 0x0), # UTF-32 (LE) ]; foreach ($boms as $b) { if (substr($str, 0, strlen($b)) == $b) { return substr($str, strlen($b)); } } return $str; } You can also check if the line is empty and skip it if so. while (($line = fgets($handle, 4096)) !== false) { $line = trim(strip_bom($line)); if ($line === '') { continue; } // process $line } You can also convert a character encoding: http://php.net/manual/en/function.mb-convert-encoding.php http://php.net/manual/en/function.iconv.php If your database is set up to store UTF data, make sure you insert data using the correct encoding. Obviously, if the file starts with the correct encoding then you don't need to do anything special.
  3. The first one is a serialized array. The second is useless without knowing what the fields are.
  4. If the page inside the iframe is in the same domain as the page with the iframe, then you can use Javascript to access the DOM of the iframe.
  5. You're not using the correct selector to check the box again, you're trying to target a "msg" tag.
  6. I would add the gzip stuff back to htaccess. You want to enable that. The server should negotiate with the browser to determine what to use, you wouldn't want the server to always use gzip if the browser didn't support it.
  7. You don't need both, in fact it might cause problems if you compress the data twice. Just let the web server do it, there's no need to use PHP for that. Just make sure PHP is using the correct MIME type.
  8. I don't think that code is going to work for anyone else, you're linking to a Javascript file on your personal computer.
  9. If you want to save data across pages on the same domain, you can use sessionStorage for that.
  10. You could replace that filter function with Array.splice. Generate the random number, use splice to remove and return the removed element, and then push the element onto the other array. function selectCubes(gates) { var cubes = ['cube_one', 'cube_two', 'cube_three', 'cube_four', 'cube_five', 'cube_six', 'cube_seven']; var selectedCubes = []; while (selectedCubes.length < gates) { selectedCubes.push(cubes.splice(Math.floor(Math.random()*cubes.length), 1)[0]); } return selectedCubes; }
  11. justsomeguy

    user id

    The vast majority of PHP scripts involve getting submitted data, interacting with a database, etc. That's why you need to learn those basics.
  12. If you don't want to reload the page then, assuming both pages are on the same domain (your page is also on ravesandboxapi.flutterwave.com), you can send an ajax request for that JSON data and modify the page when the response comes back. If it's on a different server then you need to use a server-side language to send the request, get the response, and then build the page.
  13. Save that Javascript code in an HTML file, and set the HTML file as the src of the iframe.
  14. The developer tools have a tool to inspect the elements on the page, and you can see all of the CSS rules that apply to them and where they're coming from. You can also change, disable, or add styles and see how the elements are affected. I would use that to look at the misbehaving elements to try to figure out why they're not lined up correctly. Once you know the CSS that is causing it then you can hopefully work backwards to figure out how that CSS gets applied and whether you need to change CSS rules or change Javascript that assigns classes or what.
  15. No, n is the size of the data set. If you have a single loop over the data set, then the time complexity is linear because the time will grow at about the same rate as the data set grows. If you have one loop over the data set inside another loop over the data set (or equivalent, as in your case), the time complexity is O(n^2), the time will grow at a much faster rate than the size of the data set. If you have another nested loop, time complexity is O(n^3) and you're going to be restricted to pretty small data sets if you want to see it finish. Well, the several loops are at least still linear complexity instead of exponential.
  16. The best way to determine what the problem is is to connect your phone to a Mac and debug on the desktop with the browser's developer tools, so you can inspect the relevant elements and determine what's being applied and how everything is affected.
  17. If you have nested loops, yes of course it increases. Look into algorithm time complexity, specifically big-O notation. The algorithm I posted has linear complexity, O(n), and your original one has exponential complexity, O(n^2). So, with mine, if the data set increases by 10 times, my algorithm will take roughly 10 times longer, but yours will take roughly 100 times longer. Determining algorithm complexity is one part of computer science. A great example of various complexities are the various sorting algorithms. It's really easy to come up with an exponential sorting algorithm, it's pretty easy to do things the wrong way. If you look into the various algorithms you'll see attempts to reduce time complexity to something less than exponential time.
  18. justsomeguy

    user id

    When you run that you're getting a notice about an undefined variable called $q, right? Well, look at the line number it's referring you to. Why are you using an undefined variable there, and what should the variable be? http://php.net/manual/en/mysqli.query.php You really need to pay attention to the error messages and figure out what they mean and why. PHP is trying to tell you what the problem is. Listen to it.
  19. I'm not going to modify your database and your code for you, if you want to learn we're help to teach people.
  20. It would be best to use a regular expression. You could also get the positions of the various delimiter characters and then get the text between the first and second, then the third and fourth if there are more, etc.
  21. The other three are because it returned the actual number instead of -1 if the answer is too big. You can add an if statement for that, my function returns the actual number regardless of how big it is, but that's not what the instructions asked for.
  22. That img tag you showed is also missing a quote, if that's from the original. Note the syntax highlighting in dsonesuk's reply.
  23. Maybe it's the timing. The example on that page runs every 10 milliseconds and moves the box 1 pixel at a time. If you increase the interval or increase the difference each time, it would get more choppy. If you change that example so it runs every 50 milliseconds and moves it by 5 pixels each time, you'll see that it becomes less smooth. You use it any time you need to schedule a function to run at a later time. With animations, that's exactly what you're doing, running code over time. The code that you posted above tells the browser to wait 2 seconds to run that function, and when the function runs it immediately sets the scroll position to the bottom. So you're telling the browser set the scroll position to the bottom in 2 seconds. You're not telling it to set it little by little until it gets to the bottom, you're telling it to wait 2 seconds and then set the scroll position to the bottom.
  24. Not for Javascript errors. Dreamweaver will only show issues with the design. If you want to find errors that happen during the actual runtime then you need to look in the developer console in the web browser. Would the number of images affect image placement? It doesn't seem likely.
  25. Does that work? It doesn't look like you're checking the password correctly, you're checking if $pwd is boolean true or false. It's neither. Other than that, if you want to lock an account if someone unsuccessfully tries a certain number of times, then you'll need to keep a counter for attempts for each user and increment if they get it wrong, set it to 0 if they get it right, and if it's at the limit then don't let them log in. You'll want to keep a timestamp also of the last failed attempt so you can reset it after a certain time.
×
×
  • Create New...