-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
getting info from api response - looping through array
maxxd replied to dkmarsh99's topic in PHP Coding Help
Don't get me wrong - I didn't parse your entire XML string because it's hella long. However, from the description you gave I'd start here. -
Oh, I like that idea - I ended up wrapping the couple problematic objects I've come across in if(!class_exists()) calls, which should be fine in case it hits production. I hadn't thought about logging a debug_backtrace(), though. I wish, on all accounts. Unfortunately I only came on board about 5 months ago so I've not gathered enough clout yet to say "scrap it - it sucks". I feel like I'm getting there, though, and hopefully with what was already in motion and the ideas I'm bringing in on top of that this code won't be here long. And luckily, most of the hair I have left is grey by now so it's not a huge loss. Now my liver, on the other hand, is probably really pissed at me.
-
I'm using VSCode right now, and it's finding plenty of errors. I'm pretty sure PHP Mess Detector would just give up the ghost and do itself in out of despair. Like I said, the code is old - unfortunately, it doesn't use namespaces or autoloading so reference and definition detection is spotty at best. It also includes HTML in strings put into a variable then output via a global function. The sad thing is, it's not the worst code I've seen in my time. It is, however, the first that somehow seems to keep running even after fatal errors...
-
That's what I thought - honestly the whole thing is making me crazy. That is terrifyingly possible, actually... I need to check the code on the server itself. That's what I've done for the time being. Just gotta remember not to commit until after I've triple checked everything. Thanks for the sanity check, y'all - nice to know I'm not going completely crazy. Or at least probably not, anyway.
-
Hey y'all. I've inherited a code base written in 5.6 that was at the time pretty bad and has since been abused pretty terribly; for instance, my predecessors decided to add '@'s to silence errors on mysql_* function calls instead of actually fixing things. However, there are no '@'s on the nested require statements that instantiate the same object multiple times inside other files. In production, this somehow works just fine - I get no errors displayed and no errors logged despite having error logging turned on in the php.ini and the fact that it's a freaking fatal error. However, in my docker setup I'm getting errors about declaring the same class twice, and I can't use the system enough to debug it. So I have a thought about how I can get around it locally in my docker container, but that solution can present problems when it comes to keeping track of actual changes versus changes for local development because this project has included every file in git - including the vendor and node_modules directories, as well as compiled files because ... well, reasons. So if I make changes locally to a file that shouldn't matter on the server, it will matter and will probably break things. TL;DR - is it even possible to suppress fatal errors in PHP? If so, how? Again, I feel the need to state that the only reason I'm asking is to debug the code I've inherited so I can fix it properly.
-
var_export($data) in your controller method.
-
Not to hop on gw1500se's bandwagon, but explain this as well, please...
-
What is the best table structure for use with PHP?
maxxd replied to bakertaylor28's topic in MySQL Help
I'm not sure I understand - we're in the MySQL Help forum, so are you having trouble with the SQL statement or the language you're using to run the statement? For instance, in PHP whether you're using PDO or MySQLi to interact with MySQL, or PDO or pg_* functions for PostgreSQL, the SQL is (close enough to) the same, but yes, the PHP running the statements will be very different. However, the PHP is a very different thing from the SQL and it's important to know which you mean.- 10 replies
-
- table
- database php
-
(and 3 more)
Tagged with:
-
PHP pathing difference when running on CLI vs from bash script?
maxxd replied to maxxd's topic in PHP Coding Help
I'm still looking into it, but honestly it may be something with my docker setup - I'm getting weird results where sometimes it'll work, other times it seems to just hang, or some of the services will work as expected but others won't. It seems to be pretty random, which is awesome. Thanks for taking a look and confirming that the functionality should be the same. -
PHP pathing difference when running on CLI vs from bash script?
maxxd replied to maxxd's topic in PHP Coding Help
Got distracted - sorry. So, all Credentials does is this: if(file_exists($credentials_file)){ $creds = json_decode(file_get_contents($credentials_file), true); /* etc */ } -
PHP pathing difference when running on CLI vs from bash script?
maxxd replied to maxxd's topic in PHP Coding Help
Good point, thanks. That's what I would've called it until I decided there may be a difference depending on the context, so thanks for the confirmation there! I'll have to pull up the actual code tomorrow - it's on my work system; it's inherited code, and I don't remember off the top of my head the exact code at the moment. That's what I thought, too. -
PHP pathing difference when running on CLI vs from bash script?
maxxd replied to maxxd's topic in PHP Coding Help
That's what I'm confused on, I guess. I cd to the directory containing the script on the command line, and the config.json file is in the 'config' directory that lives next to the script. The Config object actually doesn't include or require anything, it parses the values in the config.json file. So I kinda assumed that doing a cd in the shell script would actually move the location pointer (for lack of a better term - not really sure what to call it) to the script directory, but it looks like it's just creating a reference to the script directory that the php script doesn't know about? So when the php script hits the relative path of 'config/config.json' it doesn't know where to start, as opposed to './config/config.json', which gives the php a starting directory. -
What is the best table structure for use with PHP?
maxxd replied to bakertaylor28's topic in MySQL Help
MySQL queries are MySQL queries, regardless whether they're run in PHP, Ruby, MySQLWorkbench, or the command line. Unless you're using an ORM like Doctrine or Eloquent, it's all the same keywords and operations. But yes, you can have multiple criteria in a WHERE clause rather easily. Also, please keep in mind that doing a SELECT * is less efficient than selecting the fields you need specifically.- 10 replies
-
- table
- database php
-
(and 3 more)
Tagged with:
-
Hey y'all. Probably a dumb question here but I'm at a loss. I've got a PHP service script that has an include, written as so: $config = new Config('config/config.json'); The config directory is next to the PHP script and does contain the config.json file, so when I run this from the CLI everything works great. However, I've got about 17 PHP services I need to start and really don't feel like typing them all out, so I've written a shell script that does this: #!bin/bash cd /path/to/my/script /usr/local/bin/php ./my-script.php This does start the service, but it bombs out because it can't find the config.json file. If I change the PHP to $config = new Config('./config/config.json'); it works as expected from the shell script. Updating the files is technically possible, but fraught right now for reasons I can't really get into (sorry). Anybody know what the difference is, or have any ideas on how to get around this?
-
Even after your last post here I don't understand what problem you're having. You keep saying you're stuck and you need to match the QR scan with the drop-down. Is there an error message? What is the result of the QR scan? What is the value of the drop-down? Is there one or two drop-downs? What exactly isn't matching? Explain what you want to happen and what is currently happening; copy and paste any error messages you're getting, and if you're not getting any error messages make sure you've got error reporting turned on and display errors enabled. And worse come to worst, check the server logs in case it's a server error and not a php error.
-
This could be a language barrier thing, but I'm a bit confused.It sounds like the user will select a material from the second drop-down then scan a QR code that identifies the material they're scanning and that scan should match the selection from the second drop-down? If so, why? What's the thought behind making the user select a material from the second drop-down and then match that to the QR scan? Also, because the problem isn't clear at this point show the code you have, as well as any error messages or unexpected results you're getting. Assuming there's no error message and the results are unexpected, give us the results you were expecting.
-
If you're desperate to do it and kicken's far better suggestions can't or don't work for you, you can use JavaScript to find the last letter and remove it or wrap it in a span that you can then style separately. Assuming you have a way to target the specific paragraph with the last character to remove, of course.
-
var sum = (Charge - (Pay * 1.295)); document.GetElementByid('Total').value = Sum; `sum` is not the same as `Sum`. You should be getting an error in your console - open your developer's tools.
-
If you're doing it all in JavaScript, store the values as an array then stringify the array when the form is submitted (assuming you're doing a full page refresh on submit; if you're using AJAX just send the array).
-
Give your form elements IDs, and use JavaScript. When the second input changes, calculate the sum and insert it into the third input (which in the case should be read-only).
-
Sure, but how do you connect the invoice to the customer? Again, I assume that your customers can have more than one invoice throughout all of history, so that's the join you need - you need to link customer ID to customer ID between the tables, not customer ID to invoice ID.
-
Hey y'all. I'm not sure which sub-forum is most appropriate for this question, so I'm putting it here because here's where I go first. Anyway - does anybody use mkcert with Docker? It seems like a perfect solution to enable local SSL-enabled development and testing, but I'm still getting the 'Potential Security Risk' warning when I hit my local dev site. The problem is that the system I'm working on now is all about php-based "micro-services" that talk to each other via AWS SQS queues, and some (one in particular) are throwing an "Unknown SSL protocol error" when using a super old version of the AWS PHP API to move a file into an S3 bucket hosted on my localstack environment. It's not helped by the fact that I have to mix php 7.2 and 5.6 in separate docker containers in this image to get everything to play mostly OK with each other. Sorry for the rambling - it's late. My question is this: what am I missing in my mkcert setup that I'm still getting the authentication error in the browser? This is what I've got specific to this issue (I've installed wget and libnss3-tools and my image is based on php:7.4-apache: Dockerfile: # create the locally trusted SSL certificates RUN mkdir /usr/local/.ssh RUN wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64 RUN mv mkcert-v1.4.1-linux-amd64 mkcert RUN chmod +x mkcert RUN cp mkcert /usr/local/bin/ RUN mkcert -install RUN mkcert -cert-file /usr/local/.ssh/laravel-local.pem -key-file /usr/local/.ssh/laravel-local-key.pem '*.laravel.local' laravel.local localhost 127.0.0.1 Apache.conf: <VirtualHost *:80> ServerAdmin webmaster@localhost.com DocumentRoot "/var/www/html/public" ServerName "laravel.local" <Directory "/var/www/html/public/"> AllowOverride All </Directory> </VirtualHost> <VirtualHost *:443> DocumentRoot "/var/www/html/public" ServerName "laravel.local" SSLEngine On SSLCertificateFile "/usr/local/.ssh/laravel-local.pem" SSLCertificateKeyFile "/usr/local/.ssh/laravel-local-key.pem" </VirtualHost> docker-compose: laravel: build: context: . image: laravel:new volumes: - ../project:/var/www/html - ../logs/:/var/log/ ports: - 8001:80 - 443:443 environment: - ENVIRONMENT=development networks: - laravel Obviously there's more to each of the files, but I've included the pertinent parts - let me know if more would be helpful.
-
This is suspect. I assume the 'XXX (FK)' column in your initial post is actually customerId - you'll want to join on that unless your business logic is that each customer can only have one invoice in the system, ever.
-
For the life of me I've not been able to get XDebug working with VSCode and my Docker containers, so I'm deeply jealous of your setup.