-
Posts
15,290 -
Joined
-
Last visited
-
Days Won
436
Everything posted by requinix
-
Post the code you tried so we can see what the problem is.
-
Then the code you posted isn't wrong. Something else is.
-
What's the markup for the button?
-
If it doesn't function then it isn't correct. But it does need quotes.
-
When should DateTime be injected with DateTimeZone?
requinix replied to NotionCommotion's topic in PHP Coding Help
Agreed. I would rather work with them in UTC and alter how they're displayed to the user by literally altering how they're displayed to the user. So the first one. Play it safe: 1. Make sure your database abstraction can handle DateTime objects and will translate them to UTC before serializing for storage, then use DateTime instances everywhere 2. Give yourself one or more functions that can display dates to the user that will adjust the timezone as needed. This is a great way to ensure you display dates uniformly across the site, too. Note that if you're working with Immutables, you can do $userEventTime->setTimezone(new DateTimeZone(...))->format(...) But only if they're immutable. So it might be better to clone instead: (clone $userEventTime)->setTimezone(new DateTimeZone(...))->format(...) -
If you didn't have a constant named "green" then PHP was converting that to a string for you. But as of PHP 8, that will no longer happen and your script will die. PHP raised a warning when it did that. If you didn't see the warning then your PHP is not set up correctly for development.
-
gettext is a hook. What you want is the __ function. https://developer.wordpress.org/reference/functions/__/ Call it with the words to translate and stick the results into your $time_string.
-
That happens automatically. A lot of how webpages work for folks like us is declarative, meaning that you tell the browser what you want and it will deal with the how. Give the browser a standard web form, built correctly using the right information for the different pieces (eg, the form inputs will need the names "var1" and "var2"), and it will turn the form data that a user enters into the correct URL. A skeleton of the form's HTML markup is <form action="/" method="get"> <input type="text" name="var1"> <input type="text" name="var2"> <button type="submit">Submit</button> </form> That contains the absolute bare minimum information to get the behavior you want: entering "FOO" and "BAR" into the two fields and clicking the button will instruct the browser to go to "/?var1=FOO&var2=BAR".
-
Don't use PHP 8 yet? It was just released.
-
calculate total absents and presents based on user login data
requinix replied to ajoo's topic in MySQL Help
My version would be to JOIN the table to itself once or twice in order to pair up consecutive records, then DATEDIFF()-1 the end of the first with the start of the second, then SUM the results. -
Sure there's something better: your computer. 1. Create a file named whateveryouwant.html 2. Edit file in whatever editor you want 3. Open file in browser 4. ??? 5. Profit!
-
Reading Modbus-tcp registers of Solaredge inverter
requinix replied to rene's topic in PHP Coding Help
Hahaha. "I want to build a race car from scratch. It has four tires, a steering wheel that pivots them, and windshield wipers. How hard can it be?" You aren't just writing PHP code. You're writing PHP code that must observe a binary protocol communicating through a TCP socket. That is something 99% of PHP developers never have to think about in their careers. If you have a reliable spec that is relatively easy to understand then perhaps you should start there. Build your code from the ground up by dealing with the little things here and there: a function to send a specific message, a function to read a specific message, a class holding constants for all those magic numbers like 40084 and 40108. Each one of those can be written more or less by itself, and when you have enough of them, you can piece them together into something that actually does the thing you want done. Now that is something we're suitable to deal with. If you didn't create it yourself then yes: PHP doesn't have a "write" function. You will be wanting fwrite. The Python script says TCP... If it's not TCP then the initial connection to the device will fail. Which is a really easy thing to notice. And since you haven't noticed it, I imagine it hasn't happened. -
Reading Modbus-tcp registers of Solaredge inverter
requinix replied to rene's topic in PHP Coding Help
Without me trying to write the script myself, I see three options: 1. Dig deeper into the Python code to find out exactly what it does. Specifically, the ModbusClient. Translate everything in there directly to PHP code. Same class names, same method names, same everything. 2. Use a packet sniffer to see what the Python script sends versus what your script (for the same information) sends. 3. Keep the Python script, and write your output.log stuff in Python instead of PHP. -
How about... not developing your layout with jsfiddle?
-
Reading Modbus-tcp registers of Solaredge inverter
requinix replied to rene's topic in PHP Coding Help
What's the Python script, and is there some documentation online about this sort of thing? -
More or less. Try a regular CREATE TABLE with an existing table name and post the full output of what you get back from the server. Potentially. I didn't create it so I don't know what the motivation was behind creating it. I also said that it was my opinion that using IF NOT EXISTS is a symptom of a problem, and though very many people may believe otherwise, opinions are not facts.
-
PHP is Turing-complete so you can do literally anything with it. If you'd like me to share information with you about this subject, I will recommend this link.
- 2 replies
-
- php
- computer-science
-
(and 1 more)
Tagged with:
-
Can't tell from what you've posted, but would you happen to be destroying and recreating the Edit Quote buttons? Such as by replacing the contents of some ancestor container element during an AJAX request? Separately from that, 1. Make the modal show in the success handler. Otherwise it'll show immediately before the AJAX request has finished and filled in the contents. People on the internet are going to notice this effect much more than you will if you happen to be testing this locally or in a local network. 2. You're attaching the same onclick handler to every single Edit Quote button, and they all do the same thing. That's wasteful. Set up one handler that applies to all of the buttons. If you are doing the destroy/recreate thing then this will also solve your problem.
-
There is a bug, but it is not with PHP or SQLite. Echo out the $sql and try that directly. Some value somewhere, either $ime or in $_POST or in your database, is not what you think it is.
-
Why images uploaded on imgur.com service are dead?
requinix replied to mstdmstd's topic in Miscellaneous
Why are you asking here. Note that was not a question. It was a statement. https://help.imgur.com/hc/en-us -
That's it. "-p X:Y" maps the host's X to the container's Y. Make sure the container (and Apache) is running, and that you're browsing to localhost:8080. You should definitely get a connection, even if something else doesn't work.
-
Try again. And pay very close attention to what you read. Hint: What port does the Dockerfile say it will be exposing?
-
Why do you think you need a temporary table?
-
Getting closer. Read up on what the -p argument does.
-
Weird that the browser decided that it would take what you typed in and then do something else instead. Is there anything else you did differently from the example? Any redirects in place? Did you read the part in the example that talked about port mappings? No hostname means it should handle requests for every hostname. It's not a proper setup, thus the warning.