Jump to content

maxxd

Gurus
  • Posts

    1,660
  • Joined

  • Last visited

  • Days Won

    52

Posts posted by maxxd

  1. It could just be nested indexed arrays. So instead of

    foreach($employees as $employee)
    {
        echo "Name: {$employee['name']}<br>";
        echo "Department: {$employee['department']}<br>";
        echo "Salary: {$employee['salary']}<br>";
    }

    it would simply be

    foreach($employees as $employee)
    {
        echo "Name: {$employee[0]}<br>";
        echo "Department: {$employee[1]}<br>";
        echo "Salary: {$employee[2]}<br>";
    }

    Not the best pattern or most readable code, but if it's early days in the class it could get a lesson about array access across.

    Edit: this is assuming the array declaration in the initial comment is from the instructor as the system input.

  2. Not sure what's the best place for this, so mods please feel free to move it somewhere more appropriate.

    I'm having literally no luck forwarding the SSH agent from my host machine to my docker images. I'm trying to set up an image that can use composer to pull several private bitbucket repositories.

    My docker-compose file includes a composer:2 service, shares volumes with my main app service, sets an environment variable SSH_AUTH_SOCK to /ssh-auth.sock, and mounts that volume to /ssh-auth.sock in the built container. No dice.

    After several days of not being able to do it via docker-compose I copied and pasted the exact code from the official docker Composer image:

    eval $(ssh-agent); \
      docker run --rm --interactive --tty \
      --volume $PWD:/app \
      --volume $SSH_AUTH_SOCK:/ssh-auth.sock \
      --env SSH_AUTH_SOCK=/ssh-auth.sock \
      composer install

    and tried it without docker-compose; I got the same please make sure you have access to your private bitbucket repository error as I get in my compose file.

    I know this can work, but every example of it working doesn't actually work in my case so I assume I'm missing something...

    Anybody have any ideas or advice?

  3. I'm not familiar with Symfony, but yeah - rules are made to be broken, right? There are situations where a tighter coupling is not entirely unavoidable, but honestly is just easier and in the long run is not a terrible idea. Instantiating SPL objects in a class constructor is really not that awful IMO as SPL objects are unlikely to change massively without a good amount of forewarning. It can be annoying when a library comes out that does something similar to the SPL class easier, but by then you've already got the SPL code working so ... so?

  4. None of what you've given us makes sense given what you say the problem is. Assuming the line of code you say you're using:

    let searchParams = new URLSearchParams(window.location.search); var status = searchParams.get('source');

    actually is in your code - it doesn't appear in any of the code you posted - you still don't send the variable 'status' (which theoretically includes the value of the URL parameter 'source', not 'status' as the variable name implies) to $site_url()/reports/loadLeads. Also, you need to send an AJAX call to a php script (that ends in .php) and from there you can call a function - you can't call the actual php function from the URL string. And even if it did work that way, your loadLeads() method only accepts one parameter (which, admittedly, it doesn't seem to actually use), but your JS data object contains two.

    There's more beyond this, but quite honestly you need to take a step back and pick up some basics. Learn to walk before you run - I remember learning AJAX back in the day and it made no sense whatsoever until I'd done enough base-level work to actually get it. The penny dropped and it hasn't been a problem since.

  5. There's no AJAX calls in the code you've posted. If you think the error is there, perhaps post it for us to take a look. If you're using the index method for your AJAX calls (again, we don't know as we can't see the call) then it could be that it's borking because you're trying to render the entire template file instead of returning the pertinent data from the query.

    • Like 1
  6. So Barand did all the work and made a useful working script under the impression he was not only helping you with a personal project but helping someone who wanted to learn PHP. You then removed all public-facing attribution to Barand and broke the system, turned around and tried to sell the software he built and you broke, and now you offer him a 50-50 split but you can't understand why he's miffed about it?

    I mean, dude...

    • Great Answer 1
  7. As an aside, please use the code button in the post composer to paste code (it's between the quotes and the smiley face - "<>"). It helps with formatting and as long as you select PHP in the language drop-down on the right, it'll color-code your code and make it much easier to read.

  8. You won't necessarily be able to see the whitespace - depending on what IDE and character set you're using there may be an errant byte order mark in the output or there may just be too many includes to thoroughly trace. And just because you deleted opening/closing PHP tags in header.php doesn't necessarily mean that's it. For instance, you have a couple open/close tags in login.php and you don't show the full code of marina.php.

    Basically, if you have unbroken blocks of PHP, don't break up the blocks. There's no need to go in and out of PHP unless you absolutely have to, and nine out of ten times you don't. Unless you're using WordPress or an old-style or homegrown framework, in which case you will have to so be aware that it's not a great way to develop and keep a close eye on your code.

  9. Stop going in and out of PHP for no reason. In the header.php file you have whitespace before you call header_start() (it's the blank line between ?> and <?php) - you can't have output before you start a session. I'm assuming that's the error you're getting because that's a lot of strangely formatted code to go through and it's been a bit of a long day.

  10. I'm not versed in CSS frameworks for personal reasons, but is the w3-css you're talking about actually associated with w3schools.com? If it is, given the quality of the rest of the content I've seen on that site drop it immediately and move on to something else.

  11. If you echo plugin_dir_url(__FILE__); it wouldn't include 'style.css' - you didn't ask it to. However, if that output shows the correct path (including trailing slash) that leads to your styles.css everything should be working. I'd turn on error reporting in your wp-config.php file (and local dev environment) and check your logs. Another thing to check is that your css selectors are correct.

    • Like 1
  12. Also, creating the DateTimeImmutable object within the constructor couples the SomeClass with DateTimeImmutable. If you decide at a later date to switch from plain PHP to Carbon (for instance), you've got a ton of code to change.

    That's pretty much antithetical to dependency injection which - as I understand it - is the entire point of property promotion.

  13. If you're looking for the categories, select the category column and save yourself the trouble.

    $qry = "
    	SELECT category
    	FROM categories;
    ";
    
    $cats = $conn->query($qry, PDO::FETCH_ASSOC);

    Selecting '*' is inefficient in general from a SQL standpoint, and you're bound to keep running into the complexities you're seeing now. Select what you need in the mode you need it.

×
×
  • 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.