-
Posts
15,227 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
bash -c in linux? What does it actually do?
requinix replied to polaryeti's topic in Other Programming Languages
$ echo $0 -bash $ bash -c 'echo $0' bash $ bash -c 'echo $0' foo foo You can use -c if you want to run a command within bash - perhaps you need bash-specific features - and you aren't already running within bash. I'm not sure what's so complicated about that... Maybe it would be easier if you pointed out what you're confused about? -
Did you consider trying them?
-
Hard to help if you don't give any information.
-
Not able to select previous month on mobile web browser
requinix replied to Senthilkumar's topic in HTML Help
Same problem: March 30th - 1 month = February 30th -> March 2nd. -
Not able to select previous month on mobile web browser
requinix replied to Senthilkumar's topic in HTML Help
Careful with dates like March 30th... Easiest method I know: date + mktime. $previous_month = date('Y-m', mktime(0, 0, 0, date('n') - 1, 1)); -
This is an Apache question and not a PHP question, so now we're in the Apache forum. 1. Use SERVER_NAME instead of HTTP_HOST. After making sure your server is configured with the correct domain as the canonical name. 2. Instead of checking for https in one redirect and www in another, do both at the same time: if HTTPS is off or the HTTP_HOST != SERVER_NAME then redirect to the SERVER_NAME + REQUEST_URI.
-
"Incorrect string value" means you're trying to insert data that isn't valid for the column. In your case, the column is defined as utf8mb4 (aka UTF-8) but your string is not UTF-8. If the value is binary data then do not use VARCHARs in the first place. Those are for character data. Use VARBINARY instead. https://dev.mysql.com/doc/refman/8.0/en/binary-varbinary.html Either that, or you aren't supposed to be inserting raw binary data but either hex digits or a base-64 encoded version of the data...
-
You and your server disagree about where the file is. You put it in the place you want it, and you know what the path is, but what you're telling the server is not the same thing. So let's see if we can't just resolve this immediately: 1. What is the full, absolute path to the PDF file as a file? Not a URL. I mean where it exists on your server - for example, /var/www/mywebsite/admin/assets/cvs/myfile.pdf 2. What is the full, absolute path to the PHP script you want to use to download the PDF file? If you still want one. You don't have to have it. 3. In case it's not obvious from those answers, what is the full, absolute path of where your website files are hosted? For example, /var/www/mywebsite.
-
Either the path is wrong or the file is not where you think it is. I don't know what else to tell you. If the first one works then why do you want to change it?
-
convert from javascript array's to geting values from mysql tables
requinix replied to wilsoc31's topic in Javascript Help
You've dumped a whole bunch of Javascript code and asked to "convert this from Javascript array". You need to be a LOT more specific about what you want help with because nobody here is going to read through that whole thing and try to guess what you want. -
No, the path is not correct. Because if it were then all this would be working, wouldn't it? If you want to link to the PDF in your HTML then read this and give it another try: https://stackoverflow.com/questions/2005079/absolute-vs-relative-urls If you want to read the PDF with PHP code then read this one and give it another try: https://phpdelusions.net/articles/paths
-
Is there a way to encrypt the directory names in a URL?
requinix replied to CodeRed-Alpha's topic in PHP Coding Help
You can't encrypt the location because the end result is that you're still giving someone a URL to the file. Having gibberish instead of the word "documents" doesn't change that. The actual answer here is pretty simple: don't give direct links to your PDFs. Use a PHP script which authenticates the user and then outputs the file. You can use URL rewriting to transform /documents/whatever.pdf to something like /document.php?filename=whatever.pdf (which means existing URLs still work), then do something like <?php session_start(); if (!isset($_SESSION["userid"])) { // or whatever so you know if the user isn't logged in http_response_code(403); exit; } if (!isset($_GET["filename"])) { http_response_code(400); exit; } $filename = $_GET["filename"]; if (!preg_match('/^[a-z0-9_.-]+$/i', $filename)) { // potentially other characters in there http_response_code(404); exit; } $path = $_SERVER["DOCUMENT_ROOT"] . "/documents/" . $filename; // or whatever the path should be if (!is_file($path)) { http_response_code(404); exit; } $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); $mime = [ // default $extension => "application/octet-stream", // list of file types you might have "pdf" => "application/pdf", // ... ][$extension]; header("Content-Type: $mime"); header("Content-Length: " . filesize($path)); header("Content-Disposition: inline;filename=$filename"); readfile($path); -
Real time Java script calculation for update Row & column total
requinix replied to Senthilkumar's topic in Javascript Help
When you look at most sorts of Javascript UI frameworks, you see a common design: they keep an internal "model" of what the UI looks like, do work on that, and then update the actual UI with the changes. While it seems like a lot of extra work, it makes the design a lot simpler as you can manage the internal model whatever way you want instead of being forced to observe how the page is laid out. Repeating that concept here would be helpful. 1. For each row that you need to update, keep an internal array of the values of the 12 input boxes. Each one starts with a value of zero (apparently). 2. When an input is changed, go into that row's array and update the month's value. That's one half of the functionality: keeping track of when the value changes. Every time this process completes you'll have an array of the current values for the row. 3. Take that array and update the row's total. 4. Update the MS% value too? I don't know what that's supposed to be. That's the other half. Each of those halves can be done more-or-less independently of each other. Here is where I would say "Before I continue, let's clean up that HTML some because it's painful to look at" but that would take quite a bit of effort. So I won't. 😓 But there are some changes that would be really, really helpful: * Change the markup for the input boxes so that you don't have to list out the months so often by adding a data-month attribute for the month number (counting from 0) * Get rid of their IDs because (a) they're more often a bad thing than a good thing and (b) you aren't using them anyways <input type="number" class="form-control" name="Jan[]" value="" style="width:100%" data-month="0" required/> Then add some Javascript. * Don't use keyup. There's a perfectly good event exactly for this sort of thing: input * Instead of adding event handlers for every single month input, make use of the fact that Javascript "bubbles up" events and add a single event handler to cover all of them $(function() { // for each row in the table, $("#example tbody tr").each(function() { // the 12 values for the months const values = Array(12).fill(0); // a running total that can be updated every time a value changes let total = 0; // arrow function means "this" is inherited from the current scope (ie. this == the table row) const updateTotal = () => { $("[name='Total[]']", this).val(total.toString()); }; // every time something with a data-month changes its value, $(this).on("input", "[data-month]", function() { // get the new value const newvalue = parseInt(this.value || "0", 10); // update the running total total += newvalue - values[this.dataset.month]; // put the new value into the array values[this.dataset.month] = newvalue; // update the total updateTotal(); }); }); }); Demo: https://jsfiddle.net/gyhu2k57/ -
strtoupper is a PHP function. You are using Javascript. They are completely different things. newent.value is (presumably) a string. This page may be helpful to show you what you can do with it.
-
$param is an array of values. It is not an array of values where one of them is the values combined together separated by spaces. If your query has 3 integers then your parameters array needs to have 3 integers.
- 9 replies
-
- php
- bind_param
-
(and 1 more)
Tagged with:
-
Digital Signing by hashing the concatenating string in Sha256
requinix replied to Boudy's topic in PHP Coding Help
Your description doesn't say whether the signature is raw bytes in base 64-encoding or hexadecimal bytes, so you need to confirm which is those is desired. Otherwise, for the first line of code, my guess is you're not formatting the price with the correct "two decimal format". For the second, you seem to be using the merchant code value twice. Seems pretty clear to be just by looking at that line... -
Do you mean that you have it outputting "please work" at the moment you want to? The only things wrong with that second piece of code are (1) it doesn't call $citizen->selectCitizen() and (2) it's supposed to return a value ($res) that you can use to determine if it worked. You haven't really shown very much of your code, but it doesn't feel like standard MVC so far...
-
If you want help understanding what an error message means and how to fix it then you really need to tell us what the error message is.
- 1 reply
-
- 1
-
Well, first thing you're missing is valid HTML. Second is that you're using inline Javascript events from the '90s instead of modern event handlers. And third is that if you want to know about the form submitting then you should be having the form tell you when it's about to be submitted instead of the button when it's being "clicked". Fourth is that either of these is better than a confirm() dialog: 1. A checkbox in the form that says they want to do whatever it is the form does. Mark it required so the form won't submit without it being checked. Then you don't have to write any code at all. 2. A modal popup where you can customize everything and make it fit with the appearance of your site. The form's button instead triggers the modal, and the modal is what actually submits the form. Fifth is that cancelling an event requires either returning false from the inline code (which is also '90s code) or using an Event object that you can .preventDefault() on (modern).
-
Date conversion from yyyy-mm-dd to dd-mm-yyyy
requinix replied to Erwin007's topic in Javascript Help
Aww, then it's adjusting for timezones. You can go the longer route too: const from = new Date($("#from").val()).toLocaleDateString(); Javascript isn't particularly good with dates, but it can do the basics if you're willing to learn more about it. -
Date conversion from yyyy-mm-dd to dd-mm-yyyy
requinix replied to Erwin007's topic in Javascript Help
Are #from and #to date <input>s? Use .valueAsDate to get Date objects, then call their .toLocaleDateString() methods to get the date in a locale-based format. It might not be exactly dd-mm-yyyy, but (a) it's probably still good and (b) you can customize it some if you want. const from = $("#from")[0].valueAsDate.toLocaleDateString(); const to = $("#to")[0].valueAsDate.toLocaleDateString(); -
I have no idea what your hosting provider offers; if you/she uploaded the original files then you should be able to upload those files again, or if the hosting provider set up WP then they should be able to do that again. Finding out what was deleted would be really helpful - for you. Find out what files you're supposed to have, perhaps by setting up WP somewhere, and compare with the site to see what's missing. A bit more drawn out process will be to find and read whatever error messages are being created (because WP won't be just "down" without saying why) and use that as a clue. Perhaps some of those messages will be talking about trying to use files that don't exist...
-
They're log files? Is it important to recover them? Since they are just, you know, logs... Files are files. Any sort of file recovery thing appropriate for that OS and/or filesystem would work, but those tend to need low-level disk access. Did you try asking the hosting provider if they can do anything?