Jump to content

maxxd

Gurus
  • Posts

    1,352
  • Joined

  • Last visited

  • Days Won

    40

Everything posted by maxxd

  1. I'm a huge fan of soft-delete, personally. IMO the only time data should be completely and actually deleted is in the case of a GDPR request or some other situation where you can face legal action for not deleting the information completely. I've even seen setups where the user's data is replaced by basically a hash - the record still exists, any foreign records still exist and link back to the original record, but the personal data has been scrambled or blinded in some way that makes it basically useless to anyone who can view it.
  2. In addition to the above, I find PHP DocBlocker, Better Comments, Auto Close Tag, and Auto Rename Tag pretty necessary to my setups. There's a number of format and syntax plugins that I use for other languages but I would hate working in VSCode without these and Intellephense (just make sure you follow gizmola's advice).
  3. First and foremost, I hope this code isn't on a live server - you're wide open to SQL injection in many, many places. That having been said, there's also some suspect logic - for instance, line 186. Even if it were working I'm not sure you'd be getting the results you expect. Right before that, you set $stok_awal to the value of $data['qty'] or 0 if $data['qty'] is null. You then subtract $data['qty'] from $stok_awal (which again, is the value of $data['qty'] or 0) without checking to make sure that $data['qty'] exists. The basic problem here is that $data['qty'] doesn't exist. Or more to the point, $data is null. You need to output $data and see what exactly - if anything - it contains. After that, look into prepared statements and update all your queries.
  4. What error did you notice in your index.php file? Assuming the 'It has this in it,' is a copy/paste error and not actually in that php file, it looks fine (best practice is to leave off the closing php tag, but I don't think that has any bearing on your current issue). Please excuse me if this is a dumb question, but your comment about the error in Apache's log and mac_guyver's excellent point about the OS injecting file extensions got me thinking a couple things. You've tested that Apache itself is working, yeah? Like, you get the welcome page on a fresh site setup? Also, the page you're trying to serve via Apache has a '.php' extension? If you put the following code into the file 'testing.php' and the visit 'http://{yourdomain}/testing.php' you see 'Hello World!', right? <?php echo '<p>Hello World!</p>';
  5. OK, if there's no `mysqli` section in the output from phpinfo() then it's not enabled. Check your C:\PHP8\php.ini file and make sure the line `extension=mysqli.dll` doesn't have a semi-colon in front of it. Restart IIS and if that doesn't do it, then I'm sorry but somebody with more hands-on experience than I is gonna have to step in.
  6. I haven't run PHP on windows in literally a decade or longer, so I'm not sure how much help I'm going to be. Do you have a section labeled 'mysqli` in the output from `phpinfo()`? You mention in your first post that you've updated C:\PHP8\ext, but your phpinfo is showing the config as C:\PHP8\php.ini - I know in Ubuntu there's an entire folder full of extension files - mine is at `/etc/php/8.0/mods-available` and includes files like `mysqli.ini`. As a bit of an aside, is this for production or development? If you're looking at a development setup on a windows machine I highly recommend either using WSL or Docker - preferably Docker, but it's not always an option (I'm typing this on my Surface tablet that can't handle Docker so I use local installs in WSL for dev).
  7. Definitely check phpinfo() as mac_guyer recommended. Sometimes PHP uses an unexpected configuration file - check for both the Loaded Configuration File value and make sure that there's a full mysqli section in the output. Also, save yourself a ton of pain and switch to PDO now - it's much easier to deal with than mysqli overall.
  8. WP offers several sanitization functions - looks like you need sanitize_file_name().
  9. I agree with and you should heed both benananmen and gizmola's points. But for your specific question here looks - as ginerjm points to - like a question of scope. For instance, as you (I assume) learned fixing the database connection, you couldn't use $user or $pass variables within the __construct() method because you didn't pass those variables to the __construct() method. Every variable, method, and function (with some limited and typically ill-advised exceptions) has a scope outside of which it doesn't exist. So, look at where you define $data - is it in the same scope as where you use $data? Was it in the same function, or was it passed to the function that's trying to use it?
  10. The ease and method of doing what you're asking is heavily dependent on the structure of the original data, which is why I asked to see GetPosts(). I assume that's where the query is - that's what we need to see.
  11. That's kind of just a wall of poorly formatted code, so it's hard to tell where the actual problem is but let us see the GetPosts() method. What you're describing should be a data gathering concern, not a display concern. Other unsolicited advice - your entire comment output should be a method of it's own; right now the two blocks are almost identical. And I'm assuming the poor formatting is due to copy/paste issues, but on the off chance that it's not then fix that as it'll make reading your code much easier.
  12. You can't make it work without altering the code you already have. Your code doesn't take pagination into account, so in order to use pagination you must alter your code. You'll need to add a LIMIT clause to your query, then add links that target the same page with an updated starting record ID. When your page is loaded, check to see if that start number is set - if it is, it becomes the new starting offset in your SQL limit clause. If it doesn't exist, the starting offset is 0. That should be enough to put you on the right path - give it a shot and if it doesn't work post your code here with your questions.
  13. We don't know what the rest of your code looks like, so it's difficult to say what's actually happening. My biggest question is is there a reason you're not using one of the many existing PHP template engines? Personally, I'm partial to Twig when not in Laravel land.
  14. In addition to the box model, there's semantic web markup wherein the tags define the structure of the page and how important individual elements are - this is important in many different ways to many users. I think this is what everybody so far has been getting at - note that Barand used a span with the class 'headline' instead of an actual h1 tag and requinix pointed out that headings and paragraphs aren't meant to be displayed inline. It's based on the box-model structure that gizmola linked to and (i believe) informs the standard coding practices that Strider64 is talking about. This is by no means a complete explanation of the concept, but it's a decent place to start - https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Document_and_website_structure.
  15. A few things. Are you using NuSOAP? If so, the class name is `nusoap_client`, not `soapclient`. Also, please explain "And put it next to the project.". What's the value of APPPATH, and is the nusoap.php file in the folder `APPPATH.'Controllers\Payment\lib`?
  16. @gizmola - I am actually copying a composer.json file into the container and trying to run it, but it points to private bitbucket repositories and it's there that I'm running into issues. Thanks for the link and I'll let you know how it goes!
  17. A span's default display value in a browser is inline, so unless there's a reason to change it it should do what you want natively. As requinix pointed out, if it's there it may be used - try adding a helper class and overriding the display to 'inline' on that class.
  18. No, I'm just being a bit lazy and misusing the term. I mean core PHP objects and classes.
  19. Well crap. Back to Google - thanks, requinix!
  20. I am on a mac and I believe the path is correct. I've seen ssh-agent as the volume mount and tried that as well, but still nada. The one thing that's been consistent in my searching is the environment variable name - were the comments you saw about that or the mount path?
  21. 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.
  22. 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?
  23. 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?
×
×
  • 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.