-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
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.
-
Have you updated your Yoast plugin recently? Try deactivating it and see what happens.
-
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.
-
If I'm not mistaken you can schedule posts to be published at a specific time in WP. Are you sure you're not over-engineering the solution?
-
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.
-
Using wp_enqueue_style is the WP 'best practice' for getting your stylesheet into the WP templates, assuming your theme calls header() at some appropriate place. If you're still not seeing your changes, check your developers tools for 404s and inspect the source code - is your stylesheet actually found and included in the markup?
-
Not sure what the test() function is for, but your wpse_load_plugins_css() function is technically correct. I'd recommend making the handle more specific than 'style', and make sure your stylesheet is actually in the main plugin directory and not a sub-directory like `wp-content/plugins/myplugin/css/style.css`.
-
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.
-
A more efficient way is to only select the 8 rows you're looking for instead of selecting the entire table.
-
In the commented out version, $column is between $where and $rule. So, when you use the second block of code on the commented-out version of get(), 'OREDER BY RAND()' becomes $column and $rule is blank.
-
Show the action() method please. I've said it before and I get the idea that I'm yelling at the storm, but you're making your life much more complicated and harder with the DB abstraction you are creating.
-
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.
-
Excel sometimes has issues with character encoding in it's CSV export - I ran into this just the other week. You'll need to scrub your input before you can actually use it.
-
Looking to resolve 4 issues with new theme - Thanks
maxxd replied to MrBishop's topic in PHP Coding Help
I'm waiting for my WSL distro to switch from v1 to v2, so here's a little bit: #2 - $icon_img is a boolean, not an array. I'm not sure what ct_get_image_by_size() does, but it's probable something went wrong with it. #3 - See #2 #4a - Probably related to #2 #4b- Definitely related to #2. -
Using <select><option>?</option></select> to display text.
maxxd replied to Steve_Berry's topic in PHP Coding Help
That's going to put all the header values in the same option. You need to create a new option element on each iteration of the loop. -
PHP 8 requires parentheses when using nested ternary operations - https://lindevs.com/nested-ternary-operators-requires-explicit-parentheses-in-php-8-0/.
-
Pardon the unsolicited advice, but unless your DB class does something really special it looks like you're making things far more difficult than they need to be. PDO is already an abstraction class; just use it. Your query() method and call can be done as such: $qry = " SELECT username FROM users WHERE username = ? "; $sql = $pdo->prepare($qry); $sql->execute(['TechnoDiver']); die("<pre>".var_export($sql->fetchAll(), true)."</pre>"); And obviously your query is meant for SELECT statements, but keep in mind if you're planning on extending to INSERT or UPDATE the performance benefits of prepare(). From the documentation: So, at that point you're forced to recreate the prepare() method in order to bind multiple arrays of values to the same query.
-
How to consume/connect to login/registration webservice/API
maxxd replied to johnman's topic in PHP Coding Help
Given what little actual information you've given us, it sounds like a pretty basic oauth-type setup. If your third-party provider doesn't have documentation (which I have to assume they do) I'd start by looking at that for tutorials. -
I've not used docker remotely, and honestly unless you're deploying to a docker instance I'm not sure I see the benefit in doing so but that's probably just my inexperience as I still typically only use Docker for development. To answer some of your questions I'm going to point you to the docker-compose specifications. For instance, I think you've got the volume definition backward in your mind - it's ../relative/path/on/host:/absolute/path/on/container (the relative path for the host is based on the folder the docker-compose.yml file is in). As to your specific questions, I'll do the best I can: I'm not a server jock by any stretch, but AFAIK a single port can only be used by a single service. So my using 3308 for the host port on this particular MySQL container is because I've got a couple other image ports using 3306 and 3307 for their MySQL containers. My php files are located in the ../project directory as relative to the docker-compose.yml file. That's why the volume map in the laravel service is ../project:/var/www/html - the apache.conf file I've copied in the Dockerfile has the directive DOCUMENT_ROOT=/var/www/html/public. That way, Laravel files are served from localhost:8001 (note that the ports assignment in the laravel service are 8001:80 - host port 8001 maps to docker port 80). http{s}://host.docker.internal is most useful when setting up local dev versions of external endpoints within the same Docker network. For instance, if you're using the setup above, the Laravel .env DB_HOST value is 'database' - if you have a .env value for (for instance) AWS_S3_BUCKET_ENDPOINT and you're using the localstack service, that value would be http://host.docker.internal:4566. Now all this having been said, I've recently transitioned back to a situation where I'm dealing with multiple sites on single servers instead of several to many different servers that all work together as much as they can (in other words, I moved back to an agency from an app development house) and I'm finding keeping the ports and service names orderly and avoiding clashes to be a bit difficult in Docker. MAMP's ability to assign different local addresses without having to specify a port number in the URL is, quite frankly, a lifesaver. I'm still trying to figure out how it's done and to port that to my Docker setup, but so far it's not panned out.
-
I see the laravel:new, mysql:5.6, localstack/localstack:latest, and redis:latest images up and running so assuming you've got laravel set up in the ../project directory and the apache.conf file that gets copied into the image has its document_root set to /var/www/html/public, you should be able to go to http://localhost:8001 and see it. You'll not see the php-7.4-apache or debian instances in the -ps because they've been renamed. I set the 'image' property of the laravel service to 'laravel:new', so that's the image name you'll see. You should be able to connect to the instance using `docker exec -it laravel /bin/bash`. Ironically though, I'm writing this post on a system without docker so I can't test that. If you use VSCode with Microsoft's Docker extension you can see the name you'll need to use to connect - as I recall it's either 'laravel' or something like 'docker_laravel_1'.
-
You know those times where explaining your issue gets you to think about it a different way and you immediately solve your problem? Yeah. For anyone that happens across this with a similar issue, the problem was that the value being inserted was '', not null. So the duplicate entry was actually valid. I created a mutator in the model to return an actual null value if the attendee_code is empty, and everything works as expected now. Thanks again to this forum for being my eternal rubber ducky.
- 1 reply
-
- 1
-
Hi y'all. In my attendees table the attendee_code field must be unique if it is known - if not, we pretend it's fine and move on. I know that it's not the greatest idea in terms of data integrity, but given the business rules I have to work with, it is what it is. The only problem is that I'm getting a duplicate entry exception when a new record is entered into the DB with a null attendee_code if any other record has a null attendee_code. MySQL allows this, so I'm thinking this must be an eloquent thing - does anyone know what I'm missing? public function up() { Schema::create('attendees', function (Blueprint $table) { $table->id(); $table->timestamps(); $table->string('first_name'); $table->string('last_name'); $table->string('specialty'); $table->string('attendee_code')->nullable(); $table->string('npi_id')->nullable(); $table->string('address_1')->nullable(); $table->string('city')->nullable(); $table->string('state')->nullable(); $table->string('zip_code')->nullable(); $table->unique('attendee_code'); }); }
-
The images you're using from Dockerhub are collections of underlying containers. So if you go to the repo for the official PHP image you can see all the background work that goes into creating it. I use the PHP base image because the docker-php-ext-* functions abstract away a lot of the more fiddly aspects of setting up PHP that I either don't like or don't know. Also, it was built by a lot of people who are far, far better at shell scripting and docker config than I.