Jump to content

requinix

Administrators
  • Posts

    15,286
  • Joined

  • Last visited

  • Days Won

    435

Community Answers

  1. requinix's post in Why does directory listing wih array_push gives warning "the first argument is not an array" ? was marked as the answer   
    The second argument to array_push is the item you want to push. It is not an array of items you want to append. So that's a problem, though a bit separate from what you're looking at now.
    How about the return value?
  2. requinix's post in How to reflect the ball at an angle? was marked as the answer   
    You don't need physics - just a simple if/else. Assuming you're talking about vertical and horizontal walls (like those of the containing box).
    Give it a thought yourself and you'll probably find it's easier than you expect. You're already calculating the ball's "angle" using X,Y components so consider what happens to them if you have, say, a velocity {x=1, y=2} at the time when the ball encounters a horizontal wall...
  3. requinix's post in Ratings in database ala Amazon. How many of each? was marked as the answer   
    Does it have to be in your results? It would be really easy to just write a tiny bit of code that uses 0 if there aren't any ratings of a particular star count.
  4. requinix's post in Smarty template & PHP 8.1, TEXT: Function strftime() is deprecated was marked as the answer   
    Huh, it's actually doing the thing I thought it wasn't...
    Only thing left I can think of would be skipping E_DEPRECATED messages.
    set_error_handler("error_handler", E_ALL & ~E_DEPRECATED);  
  5. requinix's post in need help to figure something was marked as the answer   
    I'll give this one more try:
    1. I've already mentioned that include() will return a boolean. Specifically, true if it was able to include the file and false if it was not.
    2. You are using <?= tags instead of regular <?php. Remind yourself of what the special <?= form does.
    Do you know what happens when you combine those two together?
  6. requinix's post in JS Front End was marked as the answer   
    "Best practices" only apply to very specific questions. There is no single answer to "how do I make a login page" but there are a couple for "how do I handle password resetting".
    If you're looking to learn frontend Javascript then the most common answer is React, but there are also others like Vue and Angular that have a following.
  7. requinix's post in PHP 8.1 Showing Warnings was marked as the answer   
    You have code that ends up doing something like this:
    $variable = false; echo $variable->current; That is wrong and broken. It needs to be fixed, and making the warnings go away does not do that.
  8. requinix's post in category_page restriction was marked as the answer   
    Looks good to me.
    There are a few online tools to help build and test regular expressions, like if you want to try running a few inputs through the regex to see if they match. regex101.com and regextester.com come to mind.
    A router takes a request and routes it to a different location or resource or code path. That sounds like what you're doing.
  9. requinix's post in Bring navbar at center CSS was marked as the answer   
    So I guess you figured it out?
  10. requinix's post in issue with a update query not updating was marked as the answer   
    I'm not talking about a column in a table. I'm talking about the PHP variable you have there called $voucher_code_in_transaction. Where is the line of PHP code that declares that variable?
  11. requinix's post in Difference between an instance variable inside the class and one outside the class..? was marked as the answer   
    Forums are way better than StackOverflow for anything but the most trivial and straight-forward of questions. Forget trying to discuss anything on SO...
     
    Yes: the first one allows one and only one instance of the class, while the second allows anyone to create as many as they want.
    Which also means the first one's constructor should be private. Public could be okay but that means two paradigms for the class and that's one too many.
  12. requinix's post in best forum site out there so far, i would like to see a tutorials section appear was marked as the answer   
    But what's to prevent us from having the same "deprecated stuff" problem in a couple years? What could we do to make the tutorial concept actually successful?
    I'm not just making these questions up: I worked on a site that had the exact same idea, and we even got some people to write a few, but writing them is hard so nobody wanted to keep making more and soon the ones that had been made previously fell out of date.
    It's a great idea on paper. It's a difficult idea in practice.
  13. requinix's post in Reading binary (data structures) files help was marked as the answer   
    The one helpful part missing from your post is stating what the correct values are supposed to be. Because e484d857-00b7-4107-a58a-36ff29f6a3a5 looks like a correct GUID to me.
    Typically, though, one deals with binary file data by reading an entire "block" of stuff at once and then unpacking it.
    $data = fread($handle, 52); print_r(unpack("C4header/vversion/vlicense/v2flags/Vnames/Vnameoffset/Vfiles/Vfileoffset/Vtypes/Vtypeoffset/C16guid", $data)); Array ( [header1] => 193 [header2] => 131 [header3] => 42 [header4] => 158 [version] => 127 [license] => 29 [flags1] => 33 [flags2] => 0 [names] => 31 [nameoffset] => 72 [files] => 7 [fileoffset] => 753 [types] => 6 [typeoffset] => 711 [guid1] => 228 [guid2] => 132 [guid3] => 216 [guid4] => 87 [guid5] => 0 [guid6] => 183 [guid7] => 65 [guid8] => 7 [guid9] => 165 [guid10] => 138 [guid11] => 54 [guid12] => 255 [guid13] => 41 [guid14] => 246 [guid15] => 163 [guid16] => 165 )  
  14. requinix's post in How can you generate a sysid with PHP? was marked as the answer   
    I know an application with lots of database tables. Each record has a blargh identifier that is unique across all blarghs in the world. Do you think they're the same as sysids?
    I can't tell you how to create a "sysid". I can tell you about things like UUIDs.
  15. requinix's post in Discord Link was marked as the answer   
    Fixed.
  16. requinix's post in php install question was marked as the answer   
    Does Flywheel also have its own web server? Probably does.
    "Correct" is highly subjective. If you want to run both at once then all you actually need to do is make them run on different ports, say 8000 for one of them and 8001 for the other.
  17. requinix's post in Call function/PHP reload every 5 seconds was marked as the answer   
    Any errors in the browser console? Can you see in the developer console the browser making a network request to shipline.php?
  18. requinix's post in SAML SSO php7 app vs Microsoft app eg Teams was marked as the answer   
    Single sign-on means one place that you use to log in. It does not necessarily mean that you use it to sign in once and then nothing has to ask for your account again. In fact it shouldn't: the place with your account should be asking you each time whether you want to allow $app access to your account.
    If you coded the account stuff yourself and you're being asked multiple times then it means your app is not remembering you. If you wanted, you could have it remember you (like with a cookie) so that next time all you'd need to do is click a button to allow access.
    One way or another, you really should make sure that you have to click a button or do something - don't make the authentication completely automatic when a different app wants you to sign in. For example, in addition to remembering you, your site can also remember which apps you've allowed access to: if the same app wants access then that could be automatic, but if a different app wants access then your site should tell you first.
  19. requinix's post in Manage behaviour when comparing values. was marked as the answer   
    The general term is "CAPTCHA". Google's reCAPTCHA and whatever the non-Google alternative is, are the de-facto standards. It takes a little more work to implement but they're effective and reliable.
  20. requinix's post in Implications of final classes and final constants was marked as the answer   
    private + final doesn't make sense: if it's private then nothing can override it anyway. Just make it private.
  21. requinix's post in SQL syntax error (using SELECT FROM INNER JOIN ON WHERE) was marked as the answer   
    No it is not.
    Look at the query in your code:
    $query = "SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) WHERE krs.nim = $nim AND krs.id_thn_ak = $thn_ak"; Look at the query in the error message:
    SELECT krs.id_thn_ak ,krs.kode_matakuliah ,matakuliah.nama_matakuliah ,matakuliah.sks ,krs.nilai FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah ON (krs.kode_matakuliah = matakuliah.kode_matakuliah) They are not the same query.
    Now look at this part of the query that was shown in the error message:
    ...FROM krs WHERE krs.nim = 18024114 AND krs.id_thn_ak = INNER JOIN matakuliah... See why the query does not work?
    Now look at this part of your code:
    $this->input->post('$id_thn_ak', TRUE); Look carefully. Are you sure that is correct?
  22. requinix's post in creating an array list to become $variables was marked as the answer   
    PSA: I will remove any further posts which tell OP how to do the task as-asked. As well-intentioned as the question and its direct answer is, using variable variables is not a good thing.
  23. requinix's post in How can I anchor to a <h1 id="title1"> tag of external url? was marked as the answer   
    I don't see any H2s with ids on the page. You can't link to one of them until they are given ids.
    Why do you not have a page dedicated to showing a single article? You should be linking to that, not to some anchor buried deep on a paginated page.
  24. requinix's post in PDO not working in my function (error: "Undefined variable '$pdo'.intelephense(1008)") was marked as the answer   
    Variables defined outside of functions are not available inside of functions.
    If you need $pdo then pass it as an argument like you're already doing for $id.
  25. requinix's post in Why drawing on canvas resizing/scaling with canvas size? was marked as the answer   
    The width and height of the canvas are different from the width and height of the canvas element. What you've done is resize the element, however it will remain at its default drawable dimensions of 300x150.
    If you want to resize the canvas itself then you need to update its .width and .height.
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas
×
×
  • 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.